From ecfe60f1d88ef82ace955e6f94b2a7bb6d4c719e Mon Sep 17 00:00:00 2001 From: Joseph Dougherty Date: Thu, 25 Feb 2021 15:57:49 -0500 Subject: [PATCH] DOCS-13922 describes procedure for renaming replica sets --- source/faq/replica-sets.txt | 11 +++-- .../steps-rename-unsharded-replica-set.yaml | 49 +++++++++++++++++++ source/reference/replica-configuration.txt | 3 +- source/tutorial/manage-mongodb-processes.txt | 2 + 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 source/includes/steps-rename-unsharded-replica-set.yaml diff --git a/source/faq/replica-sets.txt b/source/faq/replica-sets.txt index a4bba6f8ad6..ae96e577c49 100644 --- a/source/faq/replica-sets.txt +++ b/source/faq/replica-sets.txt @@ -107,9 +107,10 @@ times. Can I rename a replica set? --------------------------- -No. +Yes, unsharded replica sets can be renamed. This procedure requires +downtime. -You can use the backup and restore procedure described in the -:doc:`/tutorial/restore-replica-set-from-backup` tutorial to create a -new replica set with the desired name. Downtime may be necessary in -order to ensure parity between the original replica set and the new one. +Before renaming a replica set, perform a full +:doc:`backup of your MongoDB deployment `. + +.. include:: /includes/steps/rename-unsharded-replica-set.rst diff --git a/source/includes/steps-rename-unsharded-replica-set.yaml b/source/includes/steps-rename-unsharded-replica-set.yaml new file mode 100644 index 00000000000..6708d5c2750 --- /dev/null +++ b/source/includes/steps-rename-unsharded-replica-set.yaml @@ -0,0 +1,49 @@ +title: Shutdown Replica Set Members. +level: 4 +ref: shutdown-replica-set +content: | + Follow the procedure in :ref:`Stop a Replica Set ` + to confirm that replica set members are + :ref:`shut down `. + +--- +title: Rename Replica Set Members. +level: 4 +ref: rename-replica-set-members +content: | + Perform the following steps for each replica set member: + + #. Update the replica set name in the + :ref:`configuration file ` or adjust the + :binary:`~bin.mongod` startup command if not using a + configuration file. + + #. Start the replica set member on a different port without the + :option:`--replSet ` option. + + #. Connect to the replica set member. + + #. Update the replica set name in the :ref:`local database + ` with the following commands: + + .. code-block:: javascript + + /* Set `newId` to the new replica set name */ + var newId = '' + + var doc = db.getSiblingDB("local").system.replset.findOne() + var oldId = doc._id + doc._id = newId + db.getSiblingDB("local").system.replset.save(doc) + db.getSiblingDB("local").system.replset.remove({_id: oldId}) + + #. :ref:`Shut down ` the replica set + member. + + #. Start the replica set member on its original port. If using a + configuration file, ensure the :setting:`replica set name + ` is set to the new name. Otherwise, + use the :binary:`~bin.mongod` startup command with the + :option:`--replSet ` option set to the new + replica set name. +... diff --git a/source/reference/replica-configuration.txt b/source/reference/replica-configuration.txt index b9277f71dcc..ca0431dddec 100644 --- a/source/reference/replica-configuration.txt +++ b/source/reference/replica-configuration.txt @@ -38,8 +38,7 @@ Replica Set Configuration Fields *Type*: string - The name of the replica set. Once set, you cannot change the - name of a replica set. + The name of the replica set. :rsconf:`_id` *must* be identical to the :setting:`replication.replSetName` or the value of `--replSet` diff --git a/source/tutorial/manage-mongodb-processes.txt b/source/tutorial/manage-mongodb-processes.txt index 50f0b4110b3..2562d578d73 100644 --- a/source/tutorial/manage-mongodb-processes.txt +++ b/source/tutorial/manage-mongodb-processes.txt @@ -223,6 +223,8 @@ process, use the following command: The resulting backtrace data is written to the :binary:`~bin.mongod` logfile as configured with :option:`--logpath `. +.. _stop-replica-set: + Stop a Replica Set ------------------