【问题标题】:mongoDB - how to remove a member from a replicaset, and then start a new one?mongoDB - 如何从副本集中删除成员,然后开始一个新成员?
【发布时间】:2014-11-25 20:48:11
【问题描述】:

我有一个原型,我在其中创建了一个包含 3 个成员的副本集。现在我想从副本集中删除 2 个辅助节点,并在每个辅助节点上创建新副本。

从初级开始,我做了以下事情:

rs.remove("mongohost2.domain.org:27017")
rs.remove("mongohost3.domain.org:27017")

然后,当我尝试 rs.status() 时,它正确地只显示了集合中的主节点。

现在,在 secondary2.domain.org 框上,我做了以下操作:

  1. 更改了 mongo.conf 文件 - 将副本集名称从旧的 (jls0) 更改为 jls1。
  2. 在盒子上重新启动了 mongod。

问题:

当我启动 shell 时,我可以说它没有创建副本集,因为提示没有像以前那样具有副本的名称。

这是我得到的:

me@mongohost2:~$ mongo
MongoDB shell version: 2.6.5
connecting to: test
> rs.status()
{
    "startupStatus" : 1,
    "ok" : 0,
    "errmsg" : "loading local.system.replset config (LOADINGCONFIG)"
}
> rs.initiate()
{
    "ok" : 0,
    "errmsg" : "local.oplog.rs is not empty on the initiating member.  cannot initiate."
}
> 

我在日志中发现了这个:

2014-11-25T15:11:38.876-0500 [initandlisten] waiting for connections on port 27017
2014-11-25T15:11:38.957-0500 [rsStart] warning: Failed to connect to 10.238.59.71:27017, reason: errno:111 Connection refused
2014-11-25T15:11:38.961-0500 [rsStart] replSet REMOVED
2014-11-25T15:11:38.961-0500 [rsStart] replSet info self not present in the repl set configuration:
2014-11-25T15:11:38.961-0500 [rsStart] { _id: "jls0", version: 8, members: [ { _id: 0, host: "mongohost1:27017", priority: 3.0 }, { _id: 2, host: "mongohost3.domain.org:27017" } ] }
2014-11-25T15:11:38.964-0500 [rsStart] warning: Failed to connect to 10.238.59.71:27017, reason: errno:111 Connection refused
2014-11-25T15:11:38.964-0500 [rsStart] replSet info Couldn't load config yet. Sleeping 20sec and will try again.
2014-11-25T15:11:39.237-0500 [initandlisten] connection accepted from 10.238.59.141:39443 #1 (1 connection now open)
2014-11-25T15:11:39.237-0500 [conn1] replSet set names do not match, our cmdline: jls1
2014-11-25T15:11:39.237-0500 [conn1] replSet s: jls0
2014-11-25T15:11:58.967-0500 [rsStart] warning: Failed to connect to 10.238.59.71:27017, reason: errno:111 Connection refused
2014-11-25T15:11:58.967-0500 [rsStart] replSet info Couldn't load config yet. Sleeping 20sec and will try again.
2014-11-25T15:11:59.241-0500 [conn1] replSet set names do not match, our cmdline: jls1
2014-11-25T15:11:59.241-0500 [conn1] replSet s: jls0

我还需要执行哪些其他步骤来确保此服务器现在使用它自己的副本集? 谢谢。

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    设置新副本集时需要调用rs.initialize()

    您还可以在初始化新数据集之前删除旧数据文件,或者只删除存储副本设置信息的本地.* 文件。

    【讨论】:

    • 好点re:删除旧数据。但我必须运行的命令是 rs.initiate()
    猜你喜欢
    • 1970-01-01
    • 2018-02-27
    • 2021-11-16
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 2017-01-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多