How to shut down replica set in mongodb?

Huo picture Huo · Mar 4, 2013 · Viewed 17.9k times · Source

I use ubuntu.

I start three mongod replica set as follows:

$ mongod --replSet setname --logpath "1.log" --dbpath /data/rs1 --port 27017 --smallfiles --fork
$ mongod --replSet setname --logpath "2.log" --dbpath /data/rs2 --port 27018 --smallfiles --fork
$ mongod --replSet setname --logpath "3.log" --dbpath /data/rs3 --port 27019 --smallfiles --fork

How can I shut them down?

Answer

Asya Kamsky picture Asya Kamsky · Mar 4, 2013

Run the following commands from the Unix shell:

mongo --port 27017 --eval 'db.adminCommand("shutdown")'
mongo --port 27018 --eval 'db.adminCommand("shutdown")'
mongo --port 27019 --eval 'db.adminCommand("shutdown")'