Mongodb not shutting down via --shutdown command
Solution 1
I have found that if you aren't using the default --dbpath
, you have to specify it as part of the shutdown. For example, if you start the mongod
service with /Mongo/Data
as the dbpath you have to shut it down with:
mongod --dbpath /Mongo/Data --shutdown
This works even if you aren't using the default port of 27017.
Solution 2
You can just use :
pskill mongod
Or for some *nix and linux distros:
pkill mongod
When mongod gets the SIGTERM command(default signal of kill command is SIGTERM), it will shutdown the database gracefully.
You can also check the PID of the mongod process with :
ps -ef | grep mongod
Then shutdown by:
kill <PID of mongod>
But DO NOT use kill -9 for mongod process.
Related videos on Youtube
kommradHomer
Updated on September 18, 2022Comments
-
kommradHomer over 1 year
i need help with a problem on shutting mongod down gracefully. I'm running mongodb on docker .
i run mongod like with the command :
mongod --config /etc/mongod.conf
and when i close with :
mongod --shutdown
i get the message :
There doesn't seem to be a server running with dbpath: /data/db
the message is true , because my db path is not "/data/db" .
and if i try to shut it down like :
mongod --config /etc/mongod.conf --shutdown
i get the message:
killing process with pid: 9
what is the problem ?
-
Joshua almost 9 years
pskill
might be available aspkill
on some machines (including my own) -
HANZO about 4 yearsI believe this only works on linux. docs.mongodb.com/manual/tutorial/manage-mongodb-processes/…