Renaming mongo shards

Mongo has mostly excellent documentation, yet sometimes it may not be obvious how to do some less-used configuration changes. One of these is a way to rename mongo shards.

Renaming mongo shards can be done in the following way:

  • assume you have “non-portable” naming like this – if your server addresses change for some reason, you’re in trouble:

  • let’s say you want to rename them to shard0001.example.com, shard0002.example.com, shard0003.example.com:

  • The last step is restarting all mongos instances; if possible, also restart mongod instances.