Lab Change Default data path Error

I made the config file and use mongod -f /shared/mongo.conf to run my config file which is

storage:
dbPath: “/var/mongodb/db/”
systemLog:
path: “/data/logs/mongod.log”
destination: “file”
net:
bindIp : “127.0.0.1,192.168.103.100”
port: 27000
security:
authorization: enabled
processManagement:
fork : true

But I still keep getting the error. I do not know how to go about this. I have also used vagrant halt and then restarted using vagrant up --provision. Still keep getting the same error.

vagrant@m103:/var/mongodb/db$ mongod -f /shared/mongo.conf --port 27000
about to fork child process, waiting until server is ready for connections.
forked process: 2162
ERROR: child process failed, exited with error number 1
To see additional information in this output, start without the “–fork” option.

Hi @Moonis_12781,

Please follow the steps mentioned below:

  1. Remove these lines from mongo.conf file

processManagement:
fork: true

  1. Run your config file again

mongod -f /shared/mongo.conf

You will find the error due to which your mongod is not working.

If you still face any problem in resolving the error, please let me know.

Thanks,
Sonali

I did it and I am getting the error

Failed global initialization: FileNotOpen: Failed to open “/var/mongodb/db/mongod.log”
vagrant@m103:/var/mongodb/db$ mongod -f /shared/mongo.conf

You have defined logpath as /data/logs.Does this exist with proper permissions?
It is unable to create logfile

There is something strange about your problem.

In your config file you specify log file to be /data/logs/mongod.log yet the error message indicate that it cannot open /var/mongodb/db/mongod.log. Somehow either the config file is not used or is not understood. Try without specifying --port as it is already in the config.

So I removed the logfile part of my conf file and then ran the mongod -f /shared/mongo.conf command and got this error

2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] MongoDB starting : pid=5393 port=27000 dbpath=/var/mongodb/db/ 64-bit host=m103
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] db version v3.6.11
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] git version: b4339db12bf57ffee5b84a95c6919dbd35fe31c9
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] modules: enterprise
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] build environment:
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] distarch: x86_64
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-03-16T15:54:36.814+0000 I CONTROL [initandlisten] options: { config: “/shared/mongo.conf”, net: { bindIp: “127.0.0.1,192.168.103.100”, port: 27000 }, operationProfiling: { slowOpThresholdMs: 50 }, security: { authorization: “enabled” }, storage: { dbPath: “/var/mongodb/db/” } }
2019-03-16T15:54:36.814+0000 I STORAGE [initandlisten] exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /var/mongodb/db/, terminating
2019-03-16T15:54:36.815+0000 I CONTROL [initandlisten] now exiting
2019-03-16T15:54:36.815+0000 I CONTROL [initandlisten] shutting down with code:100

I honestly do not know. Its mostly these log files that are causing my errors I guess

@Sonali_Mamgain @steevej-1495 i have an issue connecting with this config file

`storage:
dbPath: ‘/var/mongodb/db/’
net:
bindIp: 127.0.0.1,192.168.103.100
port: 27000
security:
authorization: enabled
systemLog:
path: ‘/var/mongodb/db/mongod.log’
destination: ‘file’
operationProfiling:
mode: ‘on’
slowOpThresholdMs: 50

got this error bb

Check your config file
in YAML format indentation is important
ex:
security:
authorization: enabled
Under security heading
authorization should be moved at least 2 cursors to the right
Are quotes needed?
try with and without quotes

drwxrwxrwx 15 vagrant vagrant 4096 Mar 18 20:55 var
lrwxrwxrwx 1 root root 31 Mar 12 20:46 vmlinuz -> boot/vmlinuz-3.13.0-166-generic
lrwxrwxrwx 1 root root 31 Mar 12 20:46 vmlinuz.old -> boot/vmlinuz-3.13.0-166-generic
vagrant@m103:~ ls -l /var total 52 drwxr-xr-x 2 root root 4096 Mar 15 07:03 backups drwxr-xr-x 12 root root 4096 Mar 14 06:44 cache drwxr-xr-x 3 root root 4096 Mar 14 05:31 chef drwxrwxrwt 2 root root 4096 Mar 12 20:46 crash drwxr-xr-x 50 root root 4096 Mar 14 06:44 lib drwxrwsr-x 2 root staff 4096 Apr 10 2014 local lrwxrwxrwx 1 root root 9 Mar 12 20:44 lock -> /run/lock drwxrwxr-x 11 root syslog 4096 Mar 19 03:48 log drwxr-xr-x 3 root root 4096 Mar 14 05:34 m103 drwxrwsr-x 2 root mail 4096 Mar 12 20:44 mail drwxrwxrwx 3 vagrant vagrant 4096 Mar 18 20:55 mongodb drwxr-xr-x 2 root root 4096 Mar 12 20:44 opt lrwxrwxrwx 1 root root 4 Mar 12 20:44 run -> /run drwxr-xr-x 5 root root 4096 Mar 12 20:44 spool drwxrwxrwt 2 root root 4096 Mar 12 20:47 tmp vagrant@m103:~ ls -l /var/mongodb
total 4
drwxrwxrwx 2 vagrant vagrant 4096 Mar 18 20:57 db
vagrant@m103:~ ls -l /var/mongodb/db total 0 -rw------- 1 root root 0 Mar 18 20:57 mongod.lock vagrant@m103:~

Blockquote
vagrant@m103:~$ cat /data/logs
2019-03-19T03:52:17.053+0000 I CONTROL [initandlisten] MongoDB starting : pid=2489 port=27000 dbpath=/var/mongodb/db 64-bit host=m103
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] db version v3.6.11
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] git version: b4339db12bf57ffee5b84a95c6919dbd35fe31c9
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] allocator: tcmalloc
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] modules: enterprise
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] build environment:
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] distarch: x86_64
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] target_arch: x86_64
2019-03-19T03:52:17.054+0000 I CONTROL [initandlisten] options: { config: “/home/vagrant/data/config1.yml”, net: { bindIp: “127.0.0.1,192.168.103.100”, port: 27000 }, storage: { dbPath: “/var/mongodb/db” }, systemLog: { destination: “file”, path: “/data/logs” } }
2019-03-19T03:52:17.069+0000 I STORAGE [initandlisten] exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /var/mongodb/db, terminating
2019-03-19T03:52:17.069+0000 I CONTROL [initandlisten] now exiting
2019-03-19T03:52:17.069+0000 I CONTROL [initandlisten] shutting down with code:100

Trying to figure this out, but i’m getting the “Error Number 100”, i have chown and chmod 777 /var, /var/mongodb, /var/mongodb/db an inside of my /var/mongodb/db the lock file did write, but still saying it can’t…

Are you able to create a test file in the dbpath directory?
Go to /var/mongodb/db
create a test file
touch xyz
or vi abc and save it :wq
list the files
ls -lrt

Looks strange Even with chmod 777 why it is complaining read only

sudo chmod 777 -R /var/mongodb/db/

This solves the read-only challenge

I will try this all once i get home, hopefully i’ll have enough time to get everything done. :confused:

the “ls -lrt” is what did it for me, i noticed the mongod.lock file was created by root, i deleted it and started mongod again and it was able to create a new mongod.lock and started.

Downside is with all of these issues all week trying to get everything working i missed my deadline for today… I’m not sure what to do now, do I just have to retake the course next round? Is that possible to register for the next round?

I noticed that lock.file yesterday with Timestamp of March 18th and your log TS showing Mar 19th.Thought of suggesting that but missed
Yes you can unregister and register for next avail date
or continue
Did you miss all the labs?In that case a bit difficult as you have to complete all upcoming labs and exams successfully to get 65%(min needed to pass the course)