Change the IP address of each server after mongoDB Sharded Cluster migration
Change the IP address of each server after mongoDB Sharded Cluster migration author: sylar copyright [articles are allowed to be reprinted, but the source address must be indicated by link, otherwise legal liability will be investigated.]
The mongoDB sharding server architecture is shown below:
[background description]
When mongoDB Sharded Cluster is migrated, if you use cold backup or other methods to migrate, and you need to change the IP address information recorded by each node, here's how to change the IP address [replica set]
Modify the master-slave relationship of the replica set of each fragment and the master-slave relationship of the replica set of config as follows
Config=rs.conf ()
Config.members [0] .host = "10.9.110.116virtual 30001"
Rs.reconfig (config, {force:true})
According to the actual situation, change the IP address information of each node. The number of config.members [0] is sorted naturally according to the display of rs.conf (), starting with 0, not id.
[shard part]
Modify the IP address of mongos record fragments
> use config
> db.shards.find ()
{"_ id": "kk-comic-test-shard02", "host": "kk-comic-test-shard02/10.9.70.22:30004,10.9.70.22:30005"}
{"_ id": "kk-comic-test-shard03", "host": "kk-comic-test-shard03/10.9.70.22:30007,10.9.70.22:30008"}
{"_ id": "kk-comic-test-shard01", "host": "kk-comic-test-shard01/10.9.110.116:30001,10.9.110.116:30002"}
Make the following changes to the above address:
> db.shards.update ({"_ id": "kk-comic-test-shard02"}, {$set: {"host": "kk-comic-test-shard02/10.9.110.116:30004,10.9.110.116:30005"}}, {multi: true})
> db.shards.update ({"_ id": "kk-comic-test-shard03"}, {$set: {"host": "kk-comic-test-shard03/10.9.110.116:30007,10.9.110.116:30008"}}, {multi: true})
> db.shards.update ({"_ id": "kk-comic-test-shard01"}, {$set: {"host": "kk-comic-test-shard01/10.9.110.116:30001,10.9.110.116:30002"}}, {multi: true})