Docs Menu

Docs HomeDevelop ApplicationsMongoDB Manual

Rename a Replica Set

On this page

  • Prerequisites
  • Procedure

To rename a replica set, you must shut down all members of the replica set, then configure each member's local database with the new replica set name.

This procedure requires downtime.

  • Ensure your replica set is not sharded. The renaming procedure is for unsharded replica sets only.

  • Before renaming a replica set, perform a full backup of your MongoDB deployment.


Follow the procedure in Stop a Replica Set to confirm that replica set members are shut down.


This step requires downtime as all replica members will need to be shut down.


Perform the following steps for each replica set member:

  1. Update the replica set name.

  2. Start the replica set member on a different port without the --replSet option.

  3. Connect to the replica set member.

  4. Update the replica set name in the local database with the following commands:

    /* Set `newId` to the new replica set name */
    var newId = '<new replica set name>'
    var doc = db.getSiblingDB("local").system.replset.findOne()
    var oldId = doc._id
    doc._id = newId
    db.getSiblingDB("local").system.replset.remove({_id: oldId})
  5. Shut down the replica set member.

  6. Start the replica set member on its original port.

←  Configure a Secondary's Sync TargetModify PSA Replica Set Safely →