- Sharding >
- Sharded Cluster Tutorials >
- Sharded Cluster Maintenance Tutorials >
- Migrate Config Servers with Different Hostnames
Migrate Config Servers with Different Hostnames¶
This procedure migrates a config server in a sharded cluster to a new server that uses a different hostname. Use this procedure only if the config server will not be accessible via the same hostname.
Changing a config server’s hostname requires downtime and requires restarting every process in the sharded cluster. If possible, avoid changing the hostname so that you can instead use the procedure to migrate a config server and use the same hostname.
To migrate all the config servers in a cluster, perform this procedure
for each config server separately and migrate the config servers in
reverse order from how they are listed in the mongos
instances’ configdb string. Start with the last config server
listed in the configdb string.
Disable the cluster balancer process temporarily. See Disable the Balancer for more information.
Shut down the config server to migrate.
This renders all config data for the sharded cluster “read only.”
Copy the contents of
dbpathfrom the old config server to the new config server. For example, to copy the contents ofdbpathto a machine namedmongodb.config2.example.net, use a command that resembles the following:Start the config server instance on the new system. The default invocation is:
Shut down all existing MongoDB processes. This includes:
- the
mongodinstances for the shards. - the
mongodinstances for the existing config databases. - the
mongosinstances.
- the
Restart all shard
mongodinstances.Restart the
mongodinstances for the two existing non-migrated config servers.Restart the
mongosinstances.Re-enable the balancer to allow the cluster to resume normal balancing operations. See the Disable the Balancer section for more information on managing the balancer process.