如何修改副本集配置?

编程入门 行业动态 更新时间:2024-10-19 17:23:52
本文介绍了如何修改副本集配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 mongo 2 节点集群正在运行,使用此副本集配置.

I have a mongo 2 node cluster running, with this replica set config.

config = {_id: "repl1", members:[ {_id: 0, host: 'localhost:15000'}, {_id: 1, host: '192.168.2.100:15000'}] }

我必须将这两个节点移动到新服务器上.我已将所有内容从旧服务器复制到新服务器,但由于第二个节点上的 ip 更改,我在重新配置副本配置时遇到了问题.

I have to move these both nodes on to new servers. I have copied everything from old to new servers, but I'm running into issues while reconfiguring the replica config due to ip change on the 2nd node.

我已经试过了.

config = {_id: "repl1", members:[ {_id: 0, host: 'localhost:15000'}, {_id: 1, host: '192.168.2.200:15000'}] } rs.reconfig(config) { "startupStatus" : 1, "errmsg" : "loading local.system.replset config (LOADINGCONFIG)", "ok" : 0 }

它显示了上面的消息,但没有发生变化.

It shows above message, but change is not happening.

我也尝试更改副本集名称但指向相同的数据目录.我收到以下错误:

I also tried changing replica set name but pointing to the same data dirs. I am getting the following error:

rs.initiate() { "errmsg" : "local.oplog.rs is not empty on the initiating member. cannot initiate.", "ok" : 0 }

更改 IP 但将数据保留在第二个节点上的正确步骤是什么,或者我是否需要重新创建/重新同步第二个节点?

What are the right steps to change the IP but keeping the data on the 2nd node, or do i need to recreate/resync the 2nd node?

推荐答案

好吧,我遇到了同样的问题.

Well , I had the same problem.

我不得不删除所有复制和 oplog.

I had to delete all replication and oplog.

use local db.dropDatabase()

用新的集合名称重启你的 mongo

restart your mongo with new set name

config = {_id: "repl1", members:[ {_id: 0, host: 'localhost:15000'}, {_id: 1, host: '192.168.2.100:15000'}] } rs.initiate(config)

我希望这对你也有用

更多推荐

如何修改副本集配置?

本文发布于:2023-11-28 15:25:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642950.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:副本

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!