I am very new at Mongo. I am running mongod
as described here in Mac OS X
. I am running two mongod
processes from the command line. If I need to stop the mongod
processes I just execute kill <pid of mongod>
. Is it the recommended way to stop mongod
?
mongod is the primary daemon process for the MongoDB system. It handles data requests, manages data access, and performs background management operations.
mongod is a background process used by MongoDB. The main purpose of mongod is to manage all the MongoDB server tasks. For instance, accepting requests, responding to client, and memory management. mongo is a command line shell that can interact with the client (for example, system administrators and developers).
It finally succeeded (Ubuntu 15.04) with
//1.find process by name:
$ pgrep mongo
1350
//2.kill mongod-process
$ kill 1350
This is quite late, but I had same problem now, and I found one easy way :
Esan-iMac:~$mongo admin --eval "db.shutdownServer()"
MongoDB shell version: 2.6.4
connecting to: admin
2015-02-19T10:54:22.574+0200 DBClientCursor::init call() failed
server should be down...
It's giving some odd messages, but it works.
And I made alias-command for running it easy.
alias stop-mongo='/opt/mongo/release/bin/mongo admin --eval "db.shutdownServer()"'
This works at least if you start your mongo manually (e.g. with --fork option).
The accepted answer by Esa is correct. Also, regarding whether using kill is recommended - yes, but with flag -2
or no flag, never use -9
. As mentioned in docs.
kill -2 `pgrep mongo`
Alias
alias stopmongo='kill -2 `pgrep mongo`'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With