如何替换分片副本集中的节点? [英] How to replace node in sharded replica set?
问题描述
我得到了具有两个副本集的分片式mongodb设置:
I got sharded mongodb setup with two replica sets:
mongos> db.runCommand( { listShards : 1 } )
{
"shards" : [
{
"_id" : "rs01",
"host" : "rs01/10.133.250.140:27017,10.133.250.154:27017"
},
{
"_id" : "rs02",
"host" : "rs02/10.133.242.7:27017,10.133.242.8:27017"
}
],
"ok" : 1
}
节点10.133.250.140发生故障,我用另一个替换(IP地址已更改)。复制集的重新配置非常简单,只需rs.remove()和rs.add()
现在,我必须更新rs01分片的主机配置。正确的方法是什么?
Node 10.133.250.140 just went down, and I replaced it with another one (ip-address changed). Replica set reconfiguration was pretty easy, just rs.remove() and rs.add() Now I have to update host config for shard rs01. What is proper way to do it?
推荐答案
很多时候,您需要修改分片的主机字符串。更改主机字符串的最简单方法是运行更新操作。
Many times you would need to modify the host string for a shard. The simplest way to change host string is to run an update operation.
连接到mongos并执行此操作-
Connect to mongos and do this -
> use config
> db.shards.update({ "_id" : "rs01"},{$set : { "host" : "rs01/newip:27017,anothernewip:27017"} })
您可能需要重新启动所有mongos。
You might need to restart all mongos.
希望这会有所帮助:-)
Hope this helps :-)
这篇关于如何替换分片副本集中的节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!