Skip to content

Commit 6485727

Browse files
jmd-mongojeff-allen-mongo
authored andcommitted
DOCS-13922 describes procedure for renaming replica sets
1 parent 69565bf commit 6485727

File tree

7 files changed

+110
-7
lines changed

7 files changed

+110
-7
lines changed

source/administration/replica-set-maintenance.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ replica sets.
5151
:doc:`/tutorial/configure-replica-set-secondary-sync-target`
5252
Specify the member that a secondary member synchronizes from.
5353

54+
:doc:`/tutorial/rename-unsharded-replica-set`
55+
Rename an unsharded replica set.
56+
5457

5558
.. toctree::
5659
:titlesonly:
@@ -65,3 +68,4 @@ replica sets.
6568
/tutorial/manage-chained-replication
6669
/tutorial/change-hostnames-in-a-replica-set
6770
/tutorial/configure-replica-set-secondary-sync-target
71+
/tutorial/rename-unsharded-replica-set

source/faq/replica-sets.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ times.
112112
Can I rename a replica set?
113113
---------------------------
114114

115-
No.
115+
Yes, unsharded replica sets can be renamed. This procedure requires
116+
downtime.
116117

117-
You can use the backup and restore procedure described in the
118-
:doc:`/tutorial/restore-replica-set-from-backup` tutorial to create a
119-
new replica set with the desired name. Downtime may be necessary in
120-
order to ensure parity between the original replica set and the new one.
118+
To learn how to rename your replica set, see
119+
:doc:`/tutorial/rename-unsharded-replica-set`.
120+
121+
Before renaming a replica set, perform a full
122+
:doc:`backup of your MongoDB deployment </core/backups>`.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
title: Shut down replica set members.
2+
level: 4
3+
ref: shutdown-replica-set
4+
content: |
5+
Follow the procedure in :ref:`Stop a Replica Set <stop-replica-set>`
6+
to confirm that replica set members are
7+
:ref:`shut down <terminate-mongod-processes>`.
8+
9+
.. warning::
10+
11+
This step requires downtime as all replica members will need to be
12+
shut down.
13+
14+
---
15+
title: Rename the replica set.
16+
level: 4
17+
ref: rename-the-replica-set
18+
content: |
19+
Perform the following steps for each replica set member:
20+
21+
a. Update the replica set name.
22+
23+
- If using a :ref:`configuration file <conf-file>`, set
24+
:setting:`replication.replSetName <replication.replSetName>`
25+
to the new name.
26+
27+
- If using the :binary:`~bin.mongod` startup command with
28+
the :option:`--replSet <mongod --replSet>` option, note down the
29+
new replica set name for use in step f.
30+
31+
#. Start the replica set member on a different port without the
32+
:option:`--replSet <mongod --replSet>` option.
33+
34+
#. Connect to the replica set member.
35+
36+
#. Update the replica set name in the :ref:`local database
37+
<replica-set-local-database>` with the following commands:
38+
39+
.. code-block:: javascript
40+
41+
/* Set `newId` to the new replica set name */
42+
var newId = '<new replica set name>'
43+
44+
var doc = db.getSiblingDB("local").system.replset.findOne()
45+
var oldId = doc._id
46+
doc._id = newId
47+
db.getSiblingDB("local").system.replset.save(doc)
48+
db.getSiblingDB("local").system.replset.remove({_id: oldId})
49+
50+
#. :ref:`Shut down <terminate-mongod-processes>` the replica set
51+
member.
52+
53+
#. Start the replica set member on its original port.
54+
55+
- If using a configuration file, ensure that
56+
:setting:`replication.replSetName <replication.replSetName>` is
57+
set to the new replica set name.
58+
59+
- If using the :binary:`~bin.mongod` startup command with
60+
the :option:`--replSet <mongod --replSet>` option, pass the new
61+
name of the replica set to the
62+
:option:`--replSet <mongod --replSet>` option.
63+
64+
...

source/reference/replica-configuration.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ Replica Set Configuration Fields
3838

3939
*Type*: string
4040

41-
The name of the replica set. Once set, you cannot change the
42-
name of a replica set.
41+
The name of the replica set.
4342

4443
:rsconf:`_id` *must* be identical to the
4544
:setting:`replication.replSetName` or the value of `--replSet`

source/tutorial.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Replica Sets
6161
- :doc:`/tutorial/reconfigure-replica-set-with-unavailable-members`
6262
- :doc:`/tutorial/recover-data-following-unexpected-shutdown`
6363
- :doc:`/tutorial/troubleshoot-replica-sets`
64+
- :doc:`/tutorial/rename-unsharded-replica-set`
6465

6566
Sharding
6667
~~~~~~~~

source/tutorial/manage-mongodb-processes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ Starting in MongoDB 4.0.8 (and 3.6.15), if a replica set primary receives a
197197

198198
Never use ``kill -9`` (i.e. ``SIGKILL``) to terminate a mongod instance.
199199

200+
.. _stop-replica-set:
201+
200202
Stop a Replica Set
201203
------------------
202204

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
====================
2+
Rename a Replica Set
3+
====================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
To rename a replica set, you must shut down all members of the replica
14+
set, then configure each member's ``local`` database with the new
15+
replica set name.
16+
17+
This procedure requires downtime.
18+
19+
Prerequisites
20+
-------------
21+
22+
- Ensure your replica set is not sharded. The renaming procedure
23+
is for unsharded replica sets only.
24+
25+
- Before renaming a replica set, perform a full
26+
:doc:`backup of your MongoDB deployment </core/backups>`.
27+
28+
Procedure
29+
---------
30+
31+
.. include:: /includes/steps/rename-unsharded-replica-set.rst

0 commit comments

Comments
 (0)