Change default DB path to /var/mongodb/db

vagrant@m103:~$ sudo mkdir var

vagrant@m103:~ cd var/ vagrant@m103:~/var sudo mkdir mongodb/db
mkdir: cannot create directory ‘mongodb/db’: No such file or directory
vagrant@m103:~/var$ sudo mkdir mongodb
vagrant@m103:~/var$ cd mongodb/
vagrant@m103:~/var/mongodb$ sudo mkdir db
vagrant@m103:~/var/mongodb$ cd …
vagrant@m103:~/var$ cd …
vagrant@m103:~ cd .. vagrant@m103:/home cd vagrant/
vagrant@m103:~ sudo chown vagrant var/mongodb/db vagrant@m103:~ mongod -f /shared/mongod.cfg
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] MongoDB starting : pid=7246 port=27000 dbpath=/var/mongodb/db 64-bit host=m103
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] db version v3.6.16
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] git version: 204ab367a130a4fd2db1c54b02cd6a86e4e07f56
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] modules: enterprise
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] build environment:
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] distarch: x86_64
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-12-20T10:23:51.281+0000 I CONTROL [initandlisten] options: { config: “/shared/mongod.cfg”, net: { bindIp: “127.0.0.1,192.168.103.100”, port: 27000 }, security: { authorization: “enabled” }, storage: { dbPath: “/var/mongodb/db” } }
2019-12-20T10:23:51.282+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /var/mongodb/db not found., terminating
2019-12-20T10:23:51.282+0000 F - [initandlisten] Invariant failure globalStorageEngine src/mongo/db/service_context_d.cpp 272
2019-12-20T10:23:51.282+0000 F - [initandlisten]

***aborting after invariant() failure

2019-12-20T10:23:51.291+0000 F - [initandlisten] Got signal: 6 (Aborted).

Please close the issue. I have resolved it.

1 Like