Stop Replica Set MongoDB

2020-05-19 03:49发布

The command to start a Replica Set in the MongoDB Shell is rs.initiate().

What is the opposite of this command. How do I stop the replica set?

There are commands to reconfigure the set or remove members but no way that I know off to remove the last member and therefore destroy the Replica Set.

标签: linux mongodb
3条回答
萌系小妹纸
2楼-- · 2020-05-19 04:31

It all depends on what your goal is. If you want to reuse the existing mongod as a standalone server rather than a replica set member then the steps to do that would be:

  1. Restart mongod process without --replSet argument.
  2. Drop the local database:

    use local;
    db.dropDatabase();
    
查看更多
叛逆
3楼-- · 2020-05-19 04:36

I just have this issue in production. @maganap's (Mar 15) comment saved my bacon!

Using mongodb 3.2.10, no need to dump the oplog, just do this on the first member:

use local
db.system.replset.remove({}) 

Then restart the member. It'll now still have it's oplog, and it's data. Just run:

rs.initiate()
rs.reconfig(conf)

Where conf is the new conf. Then on each of the other members, just run the trashing of the replset data above and restart them. When they start they'll join the set.

查看更多
Luminary・发光体
4楼-- · 2020-05-19 04:36

1) Go to mongo shell on Secondary servers

2) Stop the secondary servers by using below command:

use admin db.shutdownServer()

2] Go to Linux shell- on secondary servers and type below command:

sudo service mongod stop

For more information, Please check the below link:

http://www.tutespace.com/2016/03/stopping-and-starting-mongodb.html

查看更多
登录 后发表回答