问题
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
}
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?
回答1:
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.
Connect to mongos and do this -
> use config
> db.shards.update({ "_id" : "rs01"},{$set : { "host" : "rs01/newip:27017,anothernewip:27017"} })
You might need to restart all mongos.
Hope this helps :-)
回答2:
Well, removing problem shard and adding it again seems the only option.
来源:https://stackoverflow.com/questions/29918216/how-to-replace-node-in-sharded-replica-set