MongoDB is going down again and again

I’m new to mongoDB. So will try to explain my 2 issue in fewer technical terms as I’m not aware much.

  1. We’re starting mongoDB with following command,
    ./mongod --dbpath /bnsf/mongodb/data/db --logpath /bnsf/mongodb/logs/mongod.log

which capture the logs in trial environment under logs/mongod.log but not in prod. I’ve compared the settings by using db.adminCommand({getParameter:"*"}) and both are same only. And even set the profile level in PROD to 2 as follow db.setProfilingLevel(2). But still no luck. Do you know any other possibilities for logs are not captured?

  1. Once start the server, After every some hours the mongod services goes down automatically. Does anyone faced the similar issues? If so, please share your thoughts. we’ll go with every possibilities.

Since we dont have logs couldn’t able to figure out the exact root cause. Atleast if we able to enable the logs, we would come to know why its going down automatically.

TIA,
Tamil

Sounds like the userid running mongod doesn’t have write permissions to the assigned log directory.
It appears you’re using a Unix/Linux-like operating system.
If so, you should be using the system facilities to start services like mongod with a configuration file.
You might consider a review of how you installed MongoDB and perhaps try to make your setup more orthodox.

If I understand correctly you start mongod exactly the same way on trial machine and on production machine. And the way you start mongod is with:

  1. You should not be starting mongod manually, you should be using systemctl or equivalent.
  2. You should be using a configuration file.

Directories /bnsf/mongodb/data/db/ and /bnsf/mongodb/logs/ exist on both trial and production machine.

You can read the log file mongod.log on trial machine but not on production machine. I am pretty sure that if mongod cannot write to /bnsf/mongodb/logs/mongod.log it fails right away. So I will assume that it does because you would not be in the situation where

That is the first reason why I suspect that you are not looking at the right place for the logs on the production system. The second reason is

because I suspect that you current directory is /bnsf/mongodb/ on the trial machine but something else on the production machine. You really have to look for /bnsf/mongodb/logs/mongod.log rather than logs/mongod.log. Share the output of the following commands from both trial and production, just after you started mongod.

whoami
pwd
ls -ld /bnsf/mongodb/data/db/
ls -ld /bnsf/mongodb/logs/
ps -aef | grep [m]ongod
ss -tlnp | grep [2]7017

Welcome to the MongoDB Community @Tamil_Mani !

Since your command line does not include the --fork option to Start mongod as a daemon, I expect the mongod process will be terminated when the associated terminal/shell session is closed.

If logs aren’t being captured, perhaps mongod has been started without including the --logpath option. If this is the case, logs will be output to stdout in the terminal session used to start mongod.

As others have suggested, you should be running your production mongod processes using a system service facility like systemd. If MongoDB was installed using one of the official packages, a service definition should already exist. See MongoDB Installation Tutorials for details relevant to your operating system.

If you need more specific advice please confirm:

  • version of MongoDB server installed (mongod --version)
  • your operating system version

Regards,
Stennie

3 Likes

This makes so much sense.