Lab - Change the Default DB Path

I have created the required path and user changed to “vagrant”

vagrant@m103:~/first_mongod$ cd /var/mongodb/
vagrant@m103:/var/mongodb$ ls -ltr
total 4
drwxrwxrwx 2 vagrant vagrant 4096 Aug 25 2018 db
vagrant@m103:/var/mongodb$ pwd

Config FIle:

dbPath: “/var/mongodb/db/”
bindIp: “,”
port: 27000
authorization: “enabled”


vagrant@m103:~/first_mongod$ mongod -f /home/vagrant/first_mongod/first_config.conf
2019-09-24T05:56:20.260+0000 I CONTROL [initandlisten] MongoDB starting : pid=2530 port=27000 dbpath=/var/mongodb/db/ 64-bit host=m103
2019-09-24T05:56:20.261+0000 I CONTROL [initandlisten] db version v3.6.7
2019-09-24T05:56:20.261+0000 I CONTROL [initandlisten] git version: 2628472127e9f1826e02c665c1d93880a204075e
2019-09-24T05:56:20.262+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2019-09-24T05:56:20.262+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-09-24T05:56:20.262+0000 I CONTROL [initandlisten] modules: enterprise
2019-09-24T05:56:20.263+0000 I CONTROL [initandlisten] build environment:
2019-09-24T05:56:20.264+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2019-09-24T05:56:20.264+0000 I CONTROL [initandlisten] distarch: x86_64
2019-09-24T05:56:20.264+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-09-24T05:56:20.265+0000 I CONTROL [initandlisten] options: { config: “/home/vagrant/first_mongod/first_config.conf”, net: { bindIp: “,”, port: 27000 }, security: { authorization: “enabled” }, storage: { dbPath: “/var/mongodb/db/” } }
2019-09-24T05:56:20.265+0000 I STORAGE [initandlisten] exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /var/mongodb/db/, terminating
2019-09-24T05:56:20.265+0000 I CONTROL [initandlisten] now exiting
2019-09-24T05:56:20.266+0000 I CONTROL [initandlisten] shutting down with code:100

Hi @vigneshwaran18,

There can be a possibility that the issue is not with the directory structure or permissions.

Can you please check the lock file once? The lock file seems to be in contention and you might need to clear the file and re-launch your process to get it going.
Also, since you changed the directory permissions later, there is also a chance that the file is owned by root. So you might need to remove it using sudo.

Please let me know if the issue still persists.

Curriculum Support Engineer