Logging to a Different Facility : Unable to fork child process error

I am unable to fork child process .
Below is the conf i am using and error i am getting image

Error

1 Like

The principal goal of logging to a different facility is so that you can investigate what is happening. The log file will indicate you the reason why it fails.

@steevej-1495 I am attaching the logs captured in Logs.txt .
I do not see any error as such except few warnings .Can you please check and help .Logs.txt (3.4 KB)

I suspect that you already started another mongod before.

Run the command

ps -aef | grep [m]ongo

to see.

This is the response of above command :
sh-4.4# ps -aef | grep mongod
1443 root 0:00 grep mongod

I dont see any other instance running and I am still getting same error .

Run date command in the terminal, try restarting mongod and output last few lines of the log file. I want to see if dates match because you log file indicate that it started correctly. The output of ls /var/mongodb/db will be usefull.

I suspect a previous mongod did not termine correctly.

If still have error, remove the processManagement: and systemLog: section of the config file and restart.

Yes @steevej-1495 . this time i tried resetting workspace and tried everything from starting but again got same fork child process error then i did everything as u said in your last reply and i am attaching Logs for same Logs.txt (3.4 KB)
and output of ls /var/mongodb/db is as below :
WiredTiger
WiredTiger.lock
WiredTiger.turtle
WiredTiger.wt
WiredTigerLAS.wt
_mdb_catalog.wt
collection-0-8743244831109575422.wt
collection-2-8743244831109575422.wt
collection-4-8743244831109575422.wt
diagnostic.data
index-1-8743244831109575422.wt
index-3-8743244831109575422.wt
index-5-8743244831109575422.wt
index-6-8743244831109575422.wt
journal
mongod.lock
sizeStorer.wt
storage.bson

Also at the end i removed processManagement and systemLog from conf and tried to run mongod and i got Failed to set up listener: SocketException: Address in use error then i ran killall mongod command and again tried to start mongod and it worked .
But still the real problem is not solved .

I think the real problem is solved which was

The files mongod.lock and WiredTiger.lock are given the proof of that. By resetting the workspace you probably cleared the data directory.

When you get Adress in use, it means you are trying to start a second mongod at the same port. By running killall, you terminated that other mongod that was listening on the same port. Killing mongod is probably what led you to

1 Like

So how should i proceed now because again if am adding processManagement and systemLog to conf , i am getting same child fork error .

Hi @Bijender_Singh,

After resetting the workspace, you should not have any difficulty in starting the mongod instance with the required parameters post #1.

By the way, the first log file that you shared was not related to the mongod instance that you started. The process id's are different.

Let us know if you are still facing any issue.

~ Shubham

The following totally eluded me. 8-(

1 Like

Yes @Shubham_Ranjan @steevej-1495 its still not working even after resetting workspace . i have tried it several times and i proceeded to “Lab: Creating First Application User” tried there but still getting same error as in post #1
I think it would persist in future lectures also so Please help .

Hi @Bijender_Singh,

Then I guess logs files that you have shared above are not related to the mongod instances that you are starting. Because in second log file that you have shared it says waiting for connections on port 27000 that means the mongod instance started successfully.

Let’s do one thing :

  1. Complete your configuration file as per the requirements mentioned in the lab.

  2. Start the mongod instance.

  3. If it doesn’t start successfully then do the following :

    • Share the content of your configuration file

    • Share the output of this command tail -n 150 /var/mongodb/logs/mongod.log

~ Shubham

@Shubham_Ranjan . it didnt started successfully .
Conf content :
storage:
dbPath: /var/mongodb/db
net:
bindIp: localhost
port: 27000
security:
authorization: enabled
systemLog:
destination: file
path: “/var/mongodb/logs/mongod.log”
processManagement:
fork: true

output of tail -n 150 /var/mongodb/logs/mongod.log :
output.txt (3.4 KB)

Why do you conclude that it did not start correctly?

The line

waiting for connections on port 27000

in the log output indicates that your server is ready and waiting for connections on port 27000.

Please post a screenshot of the issue.

its same as in output of post #1 .
and yes i guess you are correct . i just tried the test cases and they all passed .
But i dont know why does it says “ERROR: child process failed ,exited with error number” .
what does this error really mean ?? i didnt get it .

Error 48 means there is another mongod running.

I suspect that you try to start a second mongod.

Yes i was making a mistake . i was trying to start another instance .
Thanks alot @steevej-1495 and @Shubham_Ranjan .
One last thing :slight_smile:, what does “parent exiting” means in below screenshot when i started a new instance
image

Hi Ranjan,

I am actually facing the same issue, and i tried to run the command your provided above and i got the below output:

sh-4.4# tail -n 150 /var/mongodb/logs/mongod.log
2020-06-01T06:52:18.672+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] MongoDB starting : pid=341 port=27017 dbpath=/data/db 64-bit host=kW9xgmd7qqFdswS8Wj
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] db version v4.0.5
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] allocator: system
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] modules: none
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] build environment:
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] distarch: x86_64
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] options: { processManagement: { fork: true }, systemLog: { destination: “file”, path: “/var/mongodb/logs/mongod.log” } }
2020-06-01T06:52:18.727+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-06-01T06:52:18.727+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets…
2020-06-01T06:52:18.727+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2020-06-01T06:52:18.727+0000 I CONTROL [initandlisten] now exiting
2020-06-01T06:52:18.727+0000 I CONTROL [initandlisten] shutting down with code:100
sh-4.4# tail -n 150 /var/mongodb/logs/mongod.log
2020-06-01T06:52:18.672+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] MongoDB starting : pid=341 port=27017 dbpath=/data/db 64-bit host=kW9xgmd7qqFdswS8Wj
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] db version v4.0.5
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] allocator: system
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] modules: none
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] build environment:
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] distarch: x86_64
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-06-01T06:52:18.684+0000 I CONTROL [initandlisten] options: { processManagement: { fork: true }, systemLog: { destination: “file”, path: “/var/mongodb/logs/mongod.log” } }
2020-06-01T06:52:18.727+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-06-01T06:52:18.727+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets…
2020-06-01T06:52:18.727+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2020-06-01T06:52:18.727+0000 I CONTROL [initandlisten] now exiting
2020-06-01T06:52:18.727+0000 I CONTROL [initandlisten] shutting down with code:100

Kindly help on this :slight_smile:

Thanks and Regards,

Corol

Hi @tan_corol,

As the error message indicates the /data/db directory does not exist. You can manually create this directory by running this command : mkdir -p /data/db.

But please take note of this :point_down:

If you are doing this lab [Chapter 1 - Lab: Logging to a Different Facility], then please re-read the instructions mentioned in the lab. The mongod instance is supposed to be using this directory - /var/mongodb/db as the datapath.

~ Shubham