That didn't really work. I set up a test replica set using 1.8.2 with
2 servers and made it a part of a autosharded cluster. Using
{
"_id" : "testr",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" : "box1ip1:27017"
},
{
"_id" : 1,
"host" : "box2ip1:27017"
}
]
}
When mongos connects to the configdb, it logs:
Mon Jun 27 23:01:20 [Balancer] updated set (testr) to: testr/
box1ip1:27017,box2ip1:27017
box2 is the primary.
testr:PRIMARY> cfg = rs.conf()
testr:PRIMARY> cfg.members[1].host = "box2ip2:27017"
testr:PRIMARY> rs.reconfig(cfg)
On box2, rs.status() and rs.conf() look fine. However, on box1, which
remained secondary, rs.conf() looks fine but rs.status() still lists
box2ip1. The mongos logged
Thu Jun 30 21:33:01 [ReplicaSetMonitorWatcher] updated set (testr) to:
testr/box1ip1:27017,box2ip1:27017,box2ip2:27017
After restarting the mongos,
Thu Jun 30 21:34:43 [Balancer] updated set (testr) to: testr/
box1ip1,box2ip1:27017
Thinking that I should only change the secondary, I switched the IP
back to the original configuration, reconfiged. Then, I changed the
secondary in the same way:
testr:PRIMARY> cfg = rs.conf()
testr:PRIMARY> cfg.members[0].host = "box1ip2:27017"
testr:PRIMARY> rs.reconfig(cfg)
Again, rs.conf() on both boxes look fine but rs.status() on the
primary, which I ran the reconfig from, still shows box1ip1.
rs.status() from the secondary looks fine. This time, mongos didn't
log anything while running. Restarting the mongos was scary:
Thu Jun 30 21:58:26 [Balancer] updated set (testr) to: testr/
box1ip1:27017,box1ip2:27017
Thu Jun 30 21:58:26 [Balancer] updated set (testr) to: testr/
box1ip1:27017,box1ip2:27017,box2ip1:27017
I'm thinking it would be better to perform the procedure I originally
suggested.
-raylu