Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
501 views
in Technique[技术] by (71.8m points)

macos - Can I just kill mongod to stop mongo?

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?

question from:https://stackoverflow.com/questions/21431091/can-i-just-kill-mongod-to-stop-mongo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...