@@ -9,12 +9,12 @@ Synopsis
99
1010You can force a :term:`replica set` member to become :term:`primary` by
1111giving it a higher :data:`members[n].priority` value than any other
12- member in the set. Optionally, you also can force all :term:`secondary`
13- members never to become primaries by setting their
14- :data:`members[n].priority` values to ``0``, which means they can never
15- seek :ref:`election <replica-set-elections>` as primary. Or, as
16- different approach, you can instead set all secondary members to be
17- secondary-only, as described in
12+ member in the set.
13+
14+ Optionally, you also can force a member never to become primary by
15+ setting its :data:`members[n].priority` value to ``0``, which means the
16+ member can never seek :ref:`election <replica- set-elections>` as
17+ primary. For more information, see
1818:ref:`replica-set-secondary-only-members`.
1919
2020Procedures
@@ -25,10 +25,17 @@ Procedures
2525Force a Member to be Primary by Setting its Priority High
2626~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2727
28- For this procedure, assume your current :term:`primary` is
29- ``m1.example.net`` and you'd like to force ``m3.example.net`` to be
30- primary. Also assume you have a three-member :term:`replica set` with the
31- following configuration:
28+ .. versionchanged:: 2.0
29+
30+ For more information on priorities, see :ref:`replica-set-node-priority`.
31+
32+ This procedure assumes your current :term:`primary` is
33+ ``m1.example.net`` and that you'd like to instead make ``m3.example.net`` primary.
34+ The procedure also assumes you have a three-member :term:`replica set` with the
35+ configuration below. For more information on configurations, see :ref:`Replica Set
36+ Configuration Use <replica-set-reconfiguration-usage>`.
37+
38+ This procedure assumes this configuration:
3239
3340.. code-block:: javascript
3441
@@ -72,18 +79,19 @@ following configuration:
7279 ``m1.example.net`` (typically within 10 seconds).
7380
7481 - ``m1.example.net`` sees that it no longer has highest priority and,
75- in most cases, steps down. If ``m3 .example.net`` is far behind
76- ``m1.example.net``, ``m1 .example.net`` does not step down until
77- ``m3.example.net`` is within 10 seconds of it's :ref:`optime
78- <members.optime>`. This minimizes the amount of time with no
79- primary on failover.
82+ in most cases, steps down. ``m1 .example.net`` *does not* step down
83+ if ``m3 .example.net``'s sync is far behind. In that case,
84+ ``m1.example.net`` waits until `` m3.example.net`` is within 10
85+ seconds of its optime and then steps down. This minimizes the
86+ amount of time with no primary on failover.
8087
8188 - The step down forces on election in which ``m3.example.net``
8289 becomes primary based on its :data:`members[n].priority` value.
8390
8491#. Optionally, if ``m3.example.net`` is more than 10 seconds behind
8592 ``m1.example.net``'s optime, and if you don't need to have a primary
86- designated within 10 seconds, you can force ``m1.example.net`` to step down by running:
93+ designated within 10 seconds, you can force ``m1.example.net`` to
94+ step down by running:
8795
8896 .. code-block:: javascript
8997
@@ -94,9 +102,46 @@ following configuration:
94102 When ``m3.example.net`` catches up with ``m1.example.net`` it syncs
95103 and becomes primary.
96104
97- If you change your mind and would like to make ``m1.example.net`` primary again while it waits for
98- ``m3.example.net`` to catch up, issue the following command to make ``m1.example.net`` seek election again:
105+ If you change your mind and would like to make ``m1.example.net``
106+ primary again while it waits for ``m3.example.net`` to catch up,
107+ issue the following command to make ``m1.example.net`` seek election
108+ again:
99109
100110 .. code-block:: javascript
101111
102112 db.adminCommand({replSetFreeze:0})
113+
114+ .. _replica-set-force-member-to-be-primary-via-dbcommands:
115+
116+ Force a Member to be Primary Using Database Commands
117+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118+
119+ .. versionchanged:: 1.8
120+
121+ For this procedure, assume you have a :term:`replica set` with members
122+ ``A``, ``B``, and ``C``. ``A`` is current :term:`primary`, and you want
123+ ``B`` to become primary. To do so you use :method:`rs.freeze()` and
124+ :method:`rs.stepDown()`, which are wrappers for the
125+ :dbcommand:`replSetFreeze` and :dbcommand:`replSetStepDown` commands.
126+
127+ 1. In a :program:`mongo` shell, run :method:`rs.status()` to ensure your replica
128+ set is running as expected.
129+
130+ #. In a :program:`mongo` shell connected to ``C``, freeze ``C`` so that it does
131+ not attempt to become primary for 120 seconds.
132+
133+ .. code-block:: javascript
134+
135+ rs.freeze(120)
136+
137+ #. In a :program:`mongo` shell connected to ``A``, step down ``A`` so that it is not
138+ eligible to become primary for 120 seconds:
139+
140+ .. code-block:: javascript
141+
142+ rs.stepDown(120)
143+
144+ ``B`` becomes primary.
145+
146+ .. note:: During the transition, there is a short window when no member
147+ is primary.
0 commit comments