ERROR: child process failed, exited with error number 1

I am getting the error:
ERROR: child process failed, exited with error number 1

when running mongod -f /etc/csrs_1.conf

my csrs_1.conf file is detailed below:

sharding:
clusterRole: configsvr
replication:
replSetName: m103-csrs
security:
keyFile: /var/mongodb/pki/m103-keyfile
net:
bindIp: 192.168.103.100,localhost
port: 26001
systemLog:
destination: file
path: /var/mongodb/db/csrs1.log
logAppend: true
processManagement:
fork: true
storage:
dbPath: /var/mongodb/db/csrs1

image

Is it possible to run mongod with a config file without forking?

Thanks in advance

Solved this, needed to downgrade my permissions on /var/mongodb/pki/m103-keyfile to 600 as they were too open.

Hi @Ayoub_47610,

I’m glad your issue got resolved. However, a more correct permission set would be 400.

Yes, you can do that.

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Support Engineer

I’m facing the some problem here; when creating the key file at the beginning of week 2 I did this:

sudo mkdir -p /var/mongodb/pki
sudo chown vagrant:vagrant -R /var/mongodb
openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile
chmod 600 /var/mongodb/pki/m103-keyfile

So I guess that “600” is what solved the problem for @Ayoub_47610, do I need to downgrade it to 400? How can I do this?

chmod 400 /var/mongodb/pki/m103-keyfile

I’m sure it’s not that easy…

Hi @JavierBlanco,

Changing the key file permission mode to 400 would be better but I don’t think you would get an error if you have set the permission mode to 600.

Can you please provide some more information on what you are trying to do and the issue that you are facing ?

Thanks,
Shubham Ranjan
Curriculum Support Engineer

As soon as I try to turn on the first config server:

vagrant@m103:~$ mongod --config /shared/mongod-csrs-1.conf

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

The error message suggest start without the “–fork” option to get additional information. Did you tried that? Can you share this additional information? You probably specified to fork in the configuration file and you probably specified a log file in it too. Simply looking at the last few lines of this log file will also provide the additional information.

Yes, I copied the example file for my config servers; if I delete de fork option:

2019-11-27T12:18:57.687+0000 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/var/mongodb/db/csrs1/mongod.log"

And it seems it doesn’t have created the directory:

vagrant@m103:/var/mongodb/db$ cd csrs1

-bash: cd: csrs1: No such file or directory

From my mongod-csrsr-1.conf:

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

Should I do something like this?

mkdir /var/mongodb/db/{csrs1,csrs2,csrs3}

EDIT: Indeed, I should.

Solved!

4 Likes

Directories must exist with the appropriate permissions. I think it is covered somewhere in a prior lesson.

Hi @JavierBlanco,

I’m glad your issue got resolved. If you have any other query then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

mongod -f csrs_1.conf with the below error -

What should be the correct permission -

2020-01-06T13:12:50.184+0000 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open “/var/mongodb/db/csrs1/mongod.log”
vagrant@m103:~ ls -l /var/mongodb/db/csrs1/mongod.log -rw------- 1 mongodb nogroup 30905 Jan 6 12:29 /var/mongodb/db/csrs1/mongod.log vagrant@m103:~ ls -l /var/mongodb/db/csrs1/mongod.log
-rw------- 1 mongodb nogroup 30905 Jan 6 12:29 /var/mongodb/db/csrs1/mongod.log
vagrant@m103:~ cat /var/mongodb/db/csrs1/mongod.log cat: /var/mongodb/db/csrs1/mongod.log: Permission denied vagrant@m103:~

Since your user is vagrant the file must be owned by vagrant. Your ls output indicates they belong to user mongodb. You will have to run chown to change the owner back to vagrant.

Thanks @steevej-1495,

Hi @SwapanDas,

I hope you found @steevej-1495’s response helpful. As I can see you have created a separate thread for a similar issue. So please use the other one for any further communication.

Thanks,
Shubham Ranjan
Curriculum Services Engineer