Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to shut down replica set in mongodb?

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?

like image 229
Huo Avatar asked Mar 04 '13 03:03

Huo


People also ask

How do you stop a replica set in MongoDB?

Shut down the mongod instance for the member you wish to remove. To shut down the instance, connect using mongosh and use the db. shutdownServer() method. Connect to the replica set's current primary.

How do I shut down mongod?

One liners to start or stop mongodb service using command line; To start the service use: NET START MONGODB. To stop the service use: NET STOP MONGODB.

How does MongoDB replica set work?

A replica set is a group of mongod instances that maintain the same data set. A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes.


1 Answers

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")'
like image 87
Asya Kamsky Avatar answered Nov 16 '22 04:11

Asya Kamsky