Logging Lab Error: Failed global initialization: FileNotOpen: Failed to open

Hello,

I have been working on this lab for 2 days now and I decided it’s time I asked for help.

I am doing the Different Logpath Lab and I am consistently getting the following error:

2019-03-14T19:01:23.563+0000 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/var/mongodb/db/mongod.log"

My configuration file is as follows:

systemLog:
 destination: file
 logAppend: true
 path: /var/mongodb/db/mongod.log

storage:
 dbPath: /var/mongodb/db

net:
 port: 27000
 bindIp: 127.0.0.1,192.168.103.100

security:
 authorization: enabled

operationProfiling:
 slowOpThresholdMs: 50
 mode: slowOp

NOTE : I know I left out the fork configuration option, but I only did that so that there would be some terminal output regarding errors - and I got the one at the top of this post.

I was thinking it may be due to a lack of write permission, but I have used the following terminal command as instructed:

sudo chown vagrant:vagrant /var/mongodb/db

Please help,

Thank you

The directory

must be created. I see you did chown but does the directory exist? Does the file exist? If the file was created by another owner chown’ing the directory does not change the file owner or write permission.

Thanks for responding steevej. The directory definitely exists and interestingly enough, there have been some new log files added with a different file name format. I am posting a picture from my terminal so you know exactly where I am at.

The command ls -l /var/mongodb/db/mongod.log will tell you details of the file including owner ship.

Since the mongod.lock is present, I suspect you have another instance of mongod running or that terminated abnormally.

The command ps -aef | grep mongod will show if any mongod instance are running.

snip2

As you can see, there seems to be an instance running. I believe I need to kill this process right? If so, which of the given outputs is the pid?

Thank you

The instance is not running anymore. The ps output shows the grep command because we grep’ed mongod. To not see the grep command for the ps the command should be
ps -aef | grep mongod | grep -v mongod.

It is safe to remove mongod.lock and wiredTiger.lock. You might have a file in /tmp called mongod-99999.sock that needs to be removed. 99999 is the port number, it could be 21017 if the dead mongod was running on the standard port.

If you have such a file in /tmp/ run the command ss -tlnp | grep 99999 where 99999 is the port number to see if the associated process is still running.

I am still getting error in launching mongod
mongod --dbpath “/data/db” --bind_ip “192.168.103.100,127.0.0.1” --port 27000 --auth --fork --logpath “/data/log/mongod.log”
about to fork child process, waiting until server is ready for connections.

forked process: 2362

ERROR: child process failed, exited with error number 1

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

Tried executing without fork
mongod --dbpath “/data/db” --bind_ip “192.168.103.100,127.0.0.1” --port 27000 --auth --logpath “/data/log/mongod.log”
2019-03-15T04:33:44.597+0000 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open “/data/log/mongod.log”

Memosha and steevej,

I decided to make another vagrant directory with the same vagrant and provisioning file in my host machine and basically redo the labs on this new environment and I was able to pass the lab

Issue resolved. I had permission issues for log file

Hello, how were you able to fix the permission issue? I’m having the same problem.

chown command to change the

chown vagrant:vagrant /var

then sudo chmod 777 /var/mongodb/db

I’m using Windows.:disappointed_relieved:

Don’t know what that means.

I am using mac.:open_mouth:

I would be surprise you have permission issues on Windows but it is possible if you do not have admin rights. However it is more likely that you did not created the directories first.