我有一个 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)我希望这对你也有用
更多推荐
如何修改副本集配置?
发布评论