@@ -4,43 +4,43 @@ Reconfigure a Replica Set when Members are Down
4
4
5
5
.. default-domain:: mongodb
6
6
7
- To reconfigure a :term:`replica set` when a majority of the members are
8
- down or unreachable, you must manually change the set configuration.
9
-
10
- This includes situations where you have a network partition and where
11
- neither side of the partition has a majority. In such cases the two
12
- sides of the partition cannot see each other when determining whether a
13
- majority exists (see
14
- :ref:`replica-set-elections-and-network-partitions`). Therefore, do not
15
- use scripts to reconfigure but do so manually.
16
-
17
- This section gives several procedures for reconfiguring when a majority
18
- is down. Use the procedure appropriate to your version and situation.
19
-
20
- .. note:: To reconfigure a replica set when a majority of members are
21
- running, run the :method:`rs.reconfig()` command on the current
22
- :term:`primary`. For examples of using :method:`rs.reconfig()`, see
23
- :ref:`replica-set-reconfiguration-usage`.
24
-
25
- Force a Reconfiguration when the Primary is Down
26
- ------------------------------------------------
7
+ To reconfigure a :term:`replica set` when only a *minority* of members
8
+ are down or unreachable, run the :method:`rs.reconfig()` command on the
9
+ current :term:`primary`. For examples of how to reconfigure a replica
10
+ set using :method:`rs.reconfig()`, see
11
+ :ref:`replica-set-reconfiguration-usage`.
12
+
13
+ To reconfigure a replica set when a *majority* of the members are down
14
+ or unreachable, you must manually change the set configuration as
15
+ described in the procedures in this tutorial. Use the procedure
16
+ appropriate to your version and situation.
17
+
18
+ Reconfiguring when a *majority* of members are down can include
19
+ situations where you have a network partition and where neither side of
20
+ the partition has a majority. In such cases the two sides of the
21
+ partition cannot see each other when determining whether a majority
22
+ exists (see :ref:`replica-set-elections-and-network-partitions`). In
23
+ these situations, never use scripts to reconfigure but instead
24
+ reconfigure manually, as described in the procedures here.
25
+
26
+ .. index:: replica set; reconfiguration
27
+ .. _replica-set-force-reconfiguration:
28
+
29
+ Reconfigure by Forcing the Reconfiguration
30
+ ------------------------------------------
27
31
28
32
.. versionchanged:: 2.0
29
33
30
34
This procedure lets you recover while a majority of :term:`replica set`
31
- members are down or unreachable. A member might be unreachable, for
32
- example, if it is on the wrong side of a network partition.
33
-
34
- .. TODO Question: must the primary be down for you to use this procedure?
35
-
36
- You connect to any surviving member and use the the ``force : true``
37
- option to force a reconfiguration of the replica set.
35
+ members are down or unreachable. You connect to any surviving member and
36
+ use :method:`rs.reconfig()`'s ``force`` option to force a
37
+ reconfiguration of the replica set.
38
38
39
- The ``force : true `` option manually reconfigures the set. The option is
39
+ The ``force`` option manually reconfigures the set. The option is
40
40
intended only for serious problems, such as a disaster recovery
41
- failover. Do not use ``force : true `` every time you reconfigure. Also,
42
- do not put ``force : true `` into any automatic scripts and do not use
43
- ``force : true`` when there is still a primary.
41
+ failover. Do not use ``force`` any time you reconfigure. Also, do not
42
+ include ``force`` into any automatic scripts and do not use ``force``
43
+ when there is still a primary.
44
44
45
45
To force reconfiguration:
46
46
@@ -69,7 +69,8 @@ To force reconfiguration:
69
69
cfg.members = [cfg.members[0] , cfg.members[4] , cfg.members[7]]
70
70
71
71
#. On the same member, reconfigure the set by using the
72
- :method:`rs.reconfig()` command with the ``force : true`` option:
72
+ :method:`rs.reconfig()` command with the ``force`` option set to
73
+ ``true``:
73
74
74
75
.. code-block:: javascript
75
76
@@ -79,29 +80,75 @@ To force reconfiguration:
79
80
connected to.
80
81
81
82
.. note:: When you use ``force : true``, the version number in the
82
- replica set configuration increases significantly, by tens or
83
- hundreds of thousands. This is normal and designed to prevent set
84
- version collisions if network partitioning ends.
83
+ replica set configuration increases significantly, by tens or
84
+ hundreds of thousands. This is normal and designed to prevent set
85
+ version collisions if network partitioning ends.
85
86
86
- #. If the failure or partition was only temporary, then as members
87
- recover they detect that they have been removed from the set and
88
- enter a special state where they are up but refuse to answer
89
- requests, as they are no longer syncing changes. You can now re-add
90
- them to the configuration object:
87
+ #. If any of the removed members come back online, there is the chance
88
+ they will elect a new primary, resulting in two primaries. To ensure
89
+ that the removed members do not elect a new primary, shut down or
90
+ decommission the removed members as soon as possible.
91
91
92
- Be sure that each member has the same _id it had before.
92
+ Reconfigure by Replacing the Replica Set
93
+ ----------------------------------------
93
94
94
- .. TODO why does each member have to have the same ID as before?
95
- .. The wiki said they'd have to run rs.reconfig(). Why?
95
+ The procedures here are intended mainly for MongoDB versions *prior to*
96
+ version 2.0. For post-2.0 version, the above procedure,
97
+ :ref:`replica-set-force-reconfiguration`, is recommended.
96
98
97
- Consider the following example:
99
+ These procedures are for situations where a *majority* of the
100
+ :term:`replica set` members are down or unreachable. If a majority is
101
+ *running*, then skip these procedures and instead use the
102
+ :method:`rs.reconfig()` command according to the examples in
103
+ :ref:`replica-set-reconfiguration-usage`.
98
104
99
- .. code-block:: javascript
105
+ If you run a pre-2.0 version and a majority of your replica set is down,
106
+ you have the two options described here. Both involve replacing the
107
+ replica set.
108
+
109
+ Reconfigure by Turning Off Replication
110
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111
+
112
+ This option replaces the :term:`replica set` with a :term:`standalone` server.
113
+
114
+ 1. Stop the surviving :program:`mongod` instances.
115
+
116
+ #. Perform a backup.
117
+
118
+ #. Move each surviving member's data directory to an archive folder. For example:
119
+
120
+ .. code-block:: sh
121
+
122
+ mv /data/db /data/db-old
123
+
124
+ .. optional:: You may remove the data instead.
125
+
126
+ #. Restart one of the :program:`mongod` instances *without* the
127
+ ``--replSet`` parameter.
128
+
129
+ You are back online with a single server that is not a replica set
130
+ member. Clients can use this server for both reads and writes.
131
+
132
+ Reconfigure by "Breaking the Mirror"
133
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134
+
135
+ This option selects a surviving :term:`replica set` member to be the new
136
+ :term:`primary` and to be the "seed" for a new replica set. All other
137
+ members must resync from this new primary.
138
+
139
+ 1. Stop the surviving :program:`mongod` instances.
140
+
141
+ #. Perform a backup.
142
+
143
+ #. Move each surviving member's data directory to an archive folder. For example:
144
+
145
+ .. code-block:: sh
146
+
147
+ mv /data/db /data/db-old
100
148
101
- rs.add("example.com:30003")
149
+ .. optional:: You may remove the data instead.
102
150
103
- Once you add the removed members back into the set, they detect they
104
- have been added and synchronize to the current state of the set.
151
+ #. Restart all :program:`mongod` instances with the new replica set name.
105
152
106
- Be aware that if the original primary was one of the removed members,
107
- these members may need to rollback .
153
+ #. On the new primary, add the other instances as members of the replica
154
+ set. For more information, see :doc:`/tutorial/expand-replica-set` .
0 commit comments