While running mongo as daemon process,If mongo get crashed and restarted how to confirm that? - mongodb

I am running Mongodb server as an daemon process,I suspect that the mongo gets crashed and restarted. Is there any file available to confirm the crash.I believe that everyone acquainted about mysql if its get killed and restarted. we can confirm by checking the file. In that same way we do have a file in Mongodb to check it?

By default mongod sends its logs to stdout. From the mongod --help output:
--logpath arg file to send all output to instead of stdout
--logappend append to logpath instead of over-writing
i.e. you can specifiy a log file for the daemon - or you could just use a shell redirection.
You should have a look at how your deamon process is started to find if and where a log file is written.
Some information on your system might also help us be more helpful.

Related

Unable to configure mongoDB

Im learning mongoDB and exploring its features, i try several commands when i run the terminal and mongod acts like does not care. It always starts the server even though i simply run for reading help.
Some commands that i run
mongod --help
mongod --port 5000
mongod --dbpath C:\myfolder\myproj\data\db
Everytime, no matter witch i run from the above commands it starts the server always even when searching for help. The port and path do not change also, it looks like it ingores everything other than the mongod in the terminal. Any help?
mongod starts the service, but when you close the terminal then also the service terminates.
However, usually you install mongod as a Service. See mongod.exe for details.
Maybe this package will help you: mongoDB-oneClick

mongod command is not working now. It was working before

I don't know what is the issue. Why the mongod command is not working now. It was working before. It takes some errors when I write mongod. I am using win32 operation system.
Within the error message it says "Detected unclean shutdown... mongod.lock is not empty"
This means that your mongod was not terminated gracefully - perhaps a hard kill.
In order to start your mongod process again, you'll have to delete this lock file. The path of the file from your error message should be:
C:\data\db\mongod.lock
Here is a link to the relevant documentation where they describe the process of recovering a mongod instance after it was shut down incorrectly.
https://docs.mongodb.com/manual/tutorial/recover-data-following-unexpected-shutdown/

Mongodb will not start

It has been a while since I have used Mongodb and I am running into a problem. I have an EC2 instance that had Mongodb running on it, but I had turned off the instance for a few months. After turning the instance back on, Mongodb will not start correctly. No log file is being created so I do not know what is causing the problem.
When I type:
sudo service mongodb start
I get the message:
mongodb start/running, process 2432
but mongo is not actually running and a mongod.lock file is being created.
If I type:
mongod
by itself, Mongodb will actually start and be usable. But, I must leave the terminal window up and not cancel out of the command to keep it running. I have to open up a second terminal window to access my databases. I guess my main question is how I get the mongod service to stay running itself without having to leave a terminal window open with the command running.
Sorry if my explanation doesn't make sense. Hopefully you get what I mean. Anyone have any idea what I am missing? I had this problem before months ago and was able to solve it. Sadly, I didn't write down the missing ingredient.
For that, run command using Nohup
nohup mongod &
Then you can terminate you terminal.

mongodb running only while ssh connection is kept

Hello I'm testing mongo experimental version, which doesn't have an installer and is ran from directory by putting ./mongod but the problem is that the process quits whenever I close my ssh connection. What I'm supposed to do to keep it running even after closing ssh connection?
To start the mongod process as a background daemon you should run it with the parameters --fork (run as a daemon) and --logpath (a filename for log output).
You probably want to specify the --dbpath as well (unless you are OK with the default of /data/db).
So putting that together:
$ mongod --fork --dbpath /path/to/data --logpath /path/to/mongod.log
about to fork child process, waiting until server is ready for connections.
forked process: 64043
all output going to: /path/to/mongod.log
child process started successfully, parent exiting
$
After the server starts you will be returned to a command prompt.
If you want to shut down the server gracefully, log in via the mongo shell and run db.shutdownServer().
For more information see Manage mongod Processes in the MongoDB Manual.
It looks like that it is not started as a daemon so when you close your ssh session it got HUP signal. You can avoid it by using:
nohup command-to-start-mongo &

Error while running mongo server

I am totally a beginner with mac , I get this error while trying to open the server using mongod
10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminatin
The error usually indicates that the lock file is still present from a previous run. That means that the mongod process is stil running, check:
ps auxwww | grep mongod
If it is not listed, then remove the lock file and start mongod again. If it is listed and unresponsive you may have to kill the process (assuming you cannot connect). Try a regular kill before a kill -9 etc.
If the process is not there, or you kill it successfully, remove the lock file and restart mongod - if you had journaling enabled everything should be fine. If not, you may need the repair operation suggested by Sean.
Run sudo mongodbecause you need to have admin access. From there, you just need to type in a password.
Do you have journalling enabled? If not, and your mongod instance crashed, then you may need to perform a recovery. In this case, what you should do is
start mongod with the repair switch: mongod --repair. It will run, and then terminate having deleted the lock file.
start mongod again normally.
Once you do this, I highly recommend that you enable journalling by using the --journal command line switch when you start mongod.
If I remember way back when, you need to sudo mkdir /data: I believe that MongoDB will assume that the base directory that it needs exists and won't create it on its own.