Replace a Replica Set Member¶
If you need to change the hostname of a replica set member without changing the configuration of that member or the set, you can use the operation outlined in this tutorial. For example if you must re-provision systems or rename hosts, you can use this pattern to minimize the scope of that change.
To change the hostname to mongo2.example.net for the replica set member configured at members, issue the following sequence of commands:
cfg = rs.conf() cfg.members.host = "mongo2.example.net" rs.reconfig(cfg)