MongoDB — Failed global initialization: Failed to open “var/log/mongodb/mongod.log”

mongodb-3.0

I am getting errors starting Mongod v3.0.15 in Debian linux. I had changed the /etc/mongod.conf file to use smallFiles by adding mmapv1: smallFiles: true to the storage options.

I now get the following error when I execute $mongod --config /etc/mongod.conf:

ib1:/ 514 $ mongod –config /etc/mongod.conf

2017-10-03T12:14:21.183-0500 F CONTROL Failed global initialization: FileNotOpen Failed to open "/var/log/mongodb/mongod.log"

The mongod.log file exists, and it is also defined in the mongod.conf file as in that directory.

I am able to open the /var/log/mongodb/mongod.log file myself in the shell. It hasn't been written to in a long time (months) curiously.

Any ideas?

Thanks very much,
Karen

Best Answer

You may need to change the permissions for the parents directory /var/log/ as the user running the mongod instance might not have access to it. The below code should do it

sudo chmod 755 /var/log