@@ -74,14 +74,15 @@ To force reconfiguration:
74
74
75
75
rs.reconfig(cfg, {force : true})
76
76
77
- This operation forces the replica set to elect a new primary. Often
78
- this is the member with which your :program:`mongo` shell has a
79
- connection .
77
+ This operation forces the secondary to use the new configuration. The
78
+ configuration is then propagated to all the surviving members listed
79
+ in the ``members`` array. The replica set then elects a new primary .
80
80
81
81
.. note:: When you use ``force : true``, the version number in the
82
82
replica set configuration increases significantly, by tens or
83
83
hundreds of thousands. This is normal and designed to prevent set
84
- version collisions if network partitioning ends.
84
+ version collisions if there are forced reconfigs on both sides of
85
+ a network partition and then the network partitioning ends.
85
86
86
87
#. If the failure or partition was only temporary, shut down or
87
88
decommission the removed members as soon as possible.
@@ -141,8 +142,9 @@ Reconfigure by "Breaking the Mirror"
141
142
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142
143
143
144
This option selects a surviving :term:`replica set` member to be the new
144
- :term:`primary` and to "seed" a new replica set. All other
145
- members must resync from this new primary.
145
+ :term:`primary` and to "seed" a new replica set. In this procedure, the
146
+ member to be the new primary is referred to as ``A``. All other members
147
+ will resync from this new primary.
146
148
147
149
1. Stop the surviving :program:`mongod` instances. To ensure a clean shutdown, use
148
150
an existing :term:`control script` or an invocation that resembles the
@@ -155,27 +157,32 @@ members must resync from this new primary.
155
157
Set :option:`--dbpath <mongod --dbpath>` to the data directory of your
156
158
:program:`mongod` instance.
157
159
158
- #. For all instances that will resync their data from the surviving
159
- :program:`mongod`, move the data directory (i.e. :setting:`dbpath <mongod --dbpath>`)
160
- from each surviving member to an archive . For example:
160
+ #. Move the data directories (i.e. :setting:`dbpath <mongod --dbpath>`)
161
+ for all the members except ``A``, so that all the members except ``A``
162
+ have empty data directories . For example:
161
163
162
164
.. code-block:: sh
163
165
164
166
mv /data/db /data/db-old
165
167
166
- .. optional:: If you have a backup of the database you may instead
167
- remove this data.
168
-
169
- #. Restart all :program:`mongod` instances with a new replica set
170
- name. For example, if the old set name was ``rs0``, you would invoke the :program:`mongod`
171
- instance with the following command line argument:
168
+ #. Move ``A``'s ``local.*`` files so that ``A`` has an empty ``local``
169
+ directory. For example
172
170
173
171
.. code-block:: sh
174
172
175
- mongod --replSet rs1
173
+ mkdir /data/local-old
174
+ mv /data/db/local* /data/local-old/
175
+
176
+ #. Restart the replica set members the usual way.
177
+
178
+ #. Connect to ``A`` in a :program:`mongo` shell and run :method:`rs.initiate()`
179
+ to initiate the replica set.
180
+
181
+ #. Add the other set members using :method:`rs.add()`. For example, to add a member running
182
+ on ``example.net`` at port ``27017``, you would issue this command:
183
+
184
+ .. code-block:: javascript
176
185
177
- See :setting:`replSet` and :option:`--replSet <mongod --replSet>`
178
- for more information.
186
+ rs.add("example.net:27017")
179
187
180
- #. On the new primary, add the other instances as members of the replica
181
- set. For more information, see :doc:`/tutorial/expand-replica-set`.
188
+ The added members will initial sync their data from ``A``.
0 commit comments