Mongod -f mongod-repl-1.conf file error

vagrant@m103:~$ mongod -f mongod-repl-1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 6469
ERROR: child process failed, exited with error number 1
To see additional information in this output, start without the “–fork” option.

my mongod-repl-1.conf file:

storage:
dbPath: /var/mongodb/db/1
net:
bindIp: localhost,192.168.103.100
port: 27001
security:
authorization: enabled
keyFile: /var/mongodb/pki/103-keyfile
systemLog:
destination: file
path: /var/mongodb/db/mongod1.log
logAppend: true
processManagement:
fork: true
replication:
replSetName: m103-repl

help me to solve this issue.
Thnak you.

Hi Nagesh_46115,

Usually, the exit status: 1 means:

  • already a mongod is running on the same port, check ps -ef | grep mongod or you can kill all mongod by killall mongod.
  • dbPath is not created
  • keyfile path is not correct or accessible (no permissions set)

And if all the above cases are not in favor, comment the following lines in mongod-repl-1.conf

# processManagement: 
   #  fork: true

It will show you an exact error of what’s wrong!

Kanika

vagrant@m103:~$ vi mongod-repl-1.conf

As you said i make # processManagement:
#fork: true

but it doesn’t show ant error.

vagrant@m103:~ mongod -f mongod-repl-1.conf vagrant@m103:~ ps -ef | grep mongod
vagrant 7065 6899 0 09:13 pts/0 00:00:00 grep --color=auto mongod

no mongod process is starting on same port o/p above for that.

vagrant@m103:~ vi mongod-repl-1.conf vagrant@m103:~ sudo mkdir -p /var/mongodb/pki/
vagrant@m103:~ sudo chown vagrant:vagrant /var/mongodb/pki/ vagrant@m103:~ openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile
vagrant@m103:~ chmod 400 /var/mongodb/pki/m103-keyfile vagrant@m103:~ mkdir -p /var/mongodb/db/1
vagrant@m103:~$ mongod -f mongod-repl-1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 7051
ERROR: child process failed, exited with error number 1
To see additional information in this output, start without the “–fork” option.

you can check all above commands are also worked smoothly
still i don’t find solution.
help
Thank you.

I am sorry to say, but this does not make sense after commenting the --fork option.

Can you try through mongod command and let me know if error shows:

mongod --dbPath /var/mongodb/db/1 --port 27001 --keyFile /var/mongodb/pki/103-keyfile --replSet m103-repl --bind_ip localhost,192.168.103.100

Kanika

vagrant@m103:~ ps -ef | grep mongod vagrant 7423 7196 0 09:45 pts/2 00:00:00 grep --color=auto mongod vagrant@m103:~ mkdir -p /var/mongodb/db/1
vagrant@m103:~$ mongod --dbPath /var/mongodb/db/1 --port 27001 --keyFile /var/mongodb/pki/103-keyfile --replSet m103-re
pl --bind_ip localhost,192.168.103.100
Error parsing command line: unrecognised option ‘–dbPath’
try ‘mongod --help’ for more information

Now this is the error.Even database path is set u can check to bold command.
Thank you

Hi Nagesh_46115,

Sorry for a typo in my command. here is the corrected command:

mongod --dbpath /var/mongodb/db/1 --port 27001 --keyFile /var/mongodb/pki/103-keyfile --replSet m103-repl --bind_ip localhost,192.168.103.100

Also, I would have done this after reading the error message, if you get error even after running the command, try to understand what is wrong and correct it. If not, then please let me know.

Kanika

vagrant@m103:~ sudo mkdir -p /var/mongodb/pki vagrant@m103:~ sudo chown vagrant:vagrant -R /var/mongodb
vagrant@m103:~ openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile -bash: /var/mongodb/pki/m103-keyfile: Permission denied vagrant@m103:~ chmod 600 /var/mongodb/pki/m103-keyfile
vagrant@m103:~$ mongod --dbpath /var/mongodb/db/1 --port 27001 --keyFile /var/mongodb/pki/103-keyfile --replSet m103-re
pl --bind_ip localhost,192.168.103.100
2018-10-26T09:54:30.796+0000 I ACCESS [main] Error reading file /var/mongodb/pki/103-keyfile: No such file or directory

Help me to solve this error,I am using Windows 10 OS System.

Thank you

Hi Nagesh,

Got the mistake, it is /var/mongodb/pki/m103-keyfile instead of /var/mongodb/pki/103-keyfile.

Please correct your config file and use the correct filename for keyFile.

Change it to:

Its funny it took so long to identify the issue :smiley:

Thanks,
Kanika

finally completed homework on validate_lab_remove_readd_node.

Thank you ma’am,
for help and cooperation:smiley::grin::laughing: .

1 Like

HI kanikasingla
I have the same problem and this is my error

2018-11-28T15:08:15.049+0000 I ACCESS [main] Error reading file /var/mongodb/pki/m103-keyfile: Permission denied

when I change permission of this address, I have this error

2018-11-28T15:13:51.413+0000 I ACCESS [main] permissions on /var/mongodb/pki/m103-keyfile are too open

I set permission too 600 and 741 for this too test

Hi Abolfazl_87275,

600 should work. Are you in the vagrant box?

Make sure your owner of the file matches with the user running mongod.

Suppose, I have a file here in vagrant:

   vagrant@m103:~$ ls -l /var/mongodb/pki/m103-keyfile
   -rw------- 1 vagrant vagrant 1004 Jul 24 08:36 /var/mongodb/pki/m103-keyfile

My current user is also vagrant and owner of the file is also vagrant.

Kanika

When I set chmod 600 I can’t permission to run ls but by sudo I can
this is my command

vagrant@m103:/var/mongodb$ ls -l
ls: cannot open directory .: Permission denied

vagrant@m103:/var/mongodb$ sudo ls -l
total 8
drw------- 7 vagrant vagrant 4096 Nov 28 14:10 db
drw------- 2 vagrant vagrant 4096 Nov 28 13:58 pki

vagrant@m103:/var/mongodb$ sudo ls -l pki
total 4
-rw------- 1 vagrant vagrant 1004 Nov 28 13:58 m103-keyfile

You might check the permission of /var/mongodb directory. If you want to access a file, you need two things:

  • required permission on this file

  • execute permission on its parent directory to cd into the directory

Q Yang

1 Like

thank you
I solved my problem
It was about folder permission