Child process failing

I’m trying to follow along in the video at https://university.mongodb.com/mercury/M103/2019_August/chapter/Chapter_1_The_Mongod/lesson/5a96e969dce509e56145f6a3/lecture. During the course of the video, we’re told to enter the following code at the prompt:

mongod --port 30000 --dbpath first_mongod --logpath first_/mongod. log --fork

But this consistently returns

about to fork child process, waiting until server is ready for connections.
forked process: 6611
ERROR: child process failed, exited with error number 1
To see additional information in this output, start without the “–fork” option.

What “fork option”? Does this mean the “log --fork” parameter? Okay, so I run the command again without “log --fork”:

mongod --port 30000 --dbpath first_mongod --logpath first_/mongod.

And this is what I get:

2019-08-21T04:03:38.904+0000 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open “/home/vagrant/first_/mongod.”

I’m lost. None of this is addressed in the video. Can someone clue me in? Thanks.

1 Like

Hey @Sarah_39095

So --fork is the argument not log --fork. You can read more about --fork and the rest of the options here

Anyway

Should not have a space between mongod. and log it should read --logpath first_/mongod.log

I am going to guess your error you are seeing is from incorrect file permissions. Or the dbpath or logpath cannot be found. Did you create them and change ownership to the vagrant user. Please do what the error says and run the command without --fork

mongod --port 30000 --dbpath first_mongod --logpath first_/mongod.log

And here are the docs for the rest of the options for a mongod process
https://docs.mongodb.com/manual/reference/program/mongod/#mongod

1 Like

Hi @Sarah_39095 ,

The “–fork” option is used to launch the mongod process in background and as per the prompt, please launch your mongod without just the “–fork” option to see the error printed on your screen.

The option is not “log --fork” - ‘log’ is the extension for the log file that you are passing to capture the logs for your process, for example, first_mongod/mongod.log.

Also, --dbpath is the directory that you need to store all the files created through your mongod process and this is the same directory you can use to store the log file as well. The path for the log file will be - dbpath/file_name.log.
The main issue here in your command is the erroneous logpath and also the space before “.log”.

–dbpath first_mongod --logpath first_/mongod. log

Please follow the below given steps and try re-running your command and let me know if you still face any issues.

  • Create the --dbpath directory if not already done

  • Launch your mongod process without the --fork option to check if there are any errors

  • If you need to use the “–fork” option, please pass the “–logpath” argument as well using the correct file path and the file name (with .log extension).

Additional information - All the files you need should be stored in --dbPath. To ensure you have done so correctly, please follow this - For instance, if the directory name is “/data/db”, check if you find all the files in this location using the following command -

ls -lrt /data/db

You may also refer to the following link for further information on the parameters and their usage.
https://docs.mongodb.com/manual/reference/program/mongod/

Thanks,
Muskan
Curriculum Support Engineer

I’m getting similar problem, however, when I try to do mongod --config config file without the fork option it simply goes to the next line. Nothing happens. Very frustrating.

@Raul_26412 Are you getting the exact same problem, i.e. same error message?
If it’s the exact same problem show us exactly what you’re doing.
If it’s a slightly different error, it’s best to create your own thread.