Linux 停止副本集 MongoDB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16800461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 23:03:42  来源:igfitidea点击:

Stop Replica Set MongoDB

linuxmongodb

提问by Josh Elias

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

在 MongoDB Shell 中启动副本集的命令是 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.

有一些命令可以重新配置集合或删除成员,但我不知道删除最后一个成员并因此破坏副本集的方法。

采纳答案by Asya Kamsky

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

这一切都取决于你的目标是什么。如果要将现有mongod服务器重用为独立服务器而不是副本集成员,那么执行此操作的步骤将是:

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

    use local;
    db.dropDatabase();
    
  1. --replSet参数重启 mongod 进程。
  2. 删除本地数据库:

    use local;
    db.dropDatabase();
    

回答by Shrinivas Kalangutkar

1) Go to mongo shell on Secondary servers

1) 转到辅助服务器上的 mongo shell

2) Stop the secondary servers by using below command:

2)使用以下命令停止辅助服务器:

use admin db.shutdownServer()

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

2] 转到 Linux shell- 在辅助服务器上并键入以下命令:

sudo service mongod stop

For more information, Please check the below link:

欲了解更多信息,请查看以下链接:

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

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

回答by ABrowne

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

我只是在生产中遇到这个问题。@maganap(3 月 15 日)的评论救了我的培根!

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

使用 mongodb 3.2.10,无需转储 oplog,只需在第一个成员上执行此操作:

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

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

然后重新启动成员。它现在仍然拥有它的 oplog 和它的数据。赶紧跑:

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.

其中 conf 是新的 conf。然后在其他每个成员上,只需运行上面的 replset 数据的垃圾并重新启动它们。当他们开始时,他们将加入该集合。