Issue while launching Mongod with specified path

vagrant@m103:~$ mongod --dbpath /data/db --logpath /data/log/mongod.log

2019-04-11T14:51:50.650+0000 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open “/data/log/mongod.log”

vagrant@m103:~$ cd data/log/

vagrant@m103:~/data/log$ ls

mongod.log

vagrant@m103:~/data/log$

Are you able to create file under /data/log?

touch /data/log/xyz.log
ls -lrt /data/log

Can you do ls -lrt on that mongod.log file
It must have been created before not from your invocation
cd data/log is not same as /data/log
~/data/log means your_home_dir/data/log

Thank you for the quick reply Rama Chandra .

I’m able to create it.

vagrant@m103:~$ touch ~/data/log/xyz.log

vagrant@m103:~$ ls -lrt ~/data/log

total 0

-rwxrwxrwx 1 vagrant vagrant 0 Apr 11 13:18 mongod.log

-rw-rw-r-- 1 vagrant vagrant 0 Apr 11 17:38 xyz.log

vagrant@m103:~$ ls -lrt ~/data/log/mongod.log

-rwxrwxrwx 1 vagrant vagrant 0 Apr 11 13:18 /home/vagrant/data/log/mongod.log

I guess you have to use ~/data/log/mongod.log logpath and ~/data/db for dbpath or you can use full path
/home/vagrant/data/log/mongod.log

Hi Ramineni,

Thank you for the help.

Still I’m getting the error.


vagrant@m103:~$ mongod --dbpath ~/data/db --logpath ~/data/log/mongod.log --fork

about to fork child process, waiting until server is ready for connections.

forked process: 11270

ERROR: child process failed, exited with error number 100

To see additional information in this output, start without the “–fork” option.


@Ramachandra_37567: It must have been created before not from your invocation >> firstly there are not created from the cmd, then only I created it.

Hi Ayyappa_54878

Please check the mongod.log.It will show why it is failing
Also you can run without --fork as suggested.It will show the error on screen

In my earlier note looks like you did not get me
The path you have used is /data/log and i asked you to touch file under this dir but you touched it under ~/data/log
As i told before there is difference in /data/log and ~/data/log and also Ramineni corrected.
In your latest run you corrected the path but it is failing due to some other reason which you have to investigate
So please check logs

1 Like

Hi Ayyappa_54878,

The command is fine. All you need to take care is dbPath and logPath:

The first command you used is correct, just make sure you have the directory /data/db and /data/log created and vagrant user can access it.

Directory: /data/db and ~/data/db is not same. The directories starting from slash are standard subdirectory of the root directory. You need to enable access by using command:

chown vagrant:vagrant /data/db

This command means completely different.

For any log files and error, please remove --fork option from mongod command and the error will be printed on the command line.

Kanika