Skip to content

Commit dedadd3

Browse files
Bob GrabarSam Kleinman
authored andcommitted
DOCS-2381 new steps format: adjust rs member priority
Signed-off-by: Sam Kleinman <[email protected]>
1 parent 51a973f commit dedadd3

File tree

2 files changed

+81
-56
lines changed

2 files changed

+81
-56
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
title: Copy the replica set configuration to a variable.
2+
stepnum: 1
3+
ref: copy-configration-object
4+
action:
5+
- pre: |
6+
In the :program:`mongo` shell,
7+
use :method:`rs.conf()` to retrieve the replica set configuration and
8+
assign it to a variable. For example:
9+
language: javascript
10+
code: |
11+
cfg = rs.conf()
12+
---
13+
title: Change each member's priority value.
14+
stepnum: 2
15+
ref: change-priority-values
16+
action:
17+
- pre: |
18+
Change each
19+
member's :data:`~local.system.replset.members[n].priority` value, as
20+
configured in the :data:`~local.system.replset.members`
21+
array.
22+
post: |
23+
The following example uses the ``cfg`` variable to change the
24+
priority for the first three members configured in the array.
25+
language: javascript
26+
code: |
27+
cfg.members[0].priority = 0.5
28+
cfg.members[1].priority = 2
29+
cfg.members[2].priority = 2
30+
---
31+
title: Assign the replica set the new configuration.
32+
stepnum: 3
33+
ref: assign-new-config
34+
action:
35+
- pre: |
36+
Use :method:`rs.reconfig()` to apply the new configuration.
37+
post: |
38+
For example, to assign the replica set the new
39+
configuration in from the ``cfg`` variable, issue the following:
40+
language: javascript
41+
code: |
42+
rs.reconfig(cfg)
43+
...

source/tutorial/adjust-replica-set-member-priority.txt

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,45 @@ Adjust Priority for Replica Set Member
44

55
.. default-domain:: mongodb
66

7-
To change the value of the
8-
:data:`~local.system.replset.members[n].priority` in the replica set
9-
configuration, use the following sequence of commands in the
10-
:program:`mongo` shell:
11-
12-
.. code-block:: javascript
13-
14-
cfg = rs.conf()
15-
cfg.members[0].priority = 0.5
16-
cfg.members[1].priority = 2
17-
cfg.members[2].priority = 2
18-
rs.reconfig(cfg)
19-
20-
The first operation uses :method:`rs.conf()` to set the local variable
21-
``cfg`` to the contents of the current replica set configuration, which
22-
is a :term:`document`. The next three operations change the
23-
:data:`~local.system.replset.members[n].priority` value in the ``cfg``
24-
document for the first three members configured in the :data:`members
25-
<local.system.replset.members>` array. The final operation calls
26-
:method:`rs.reconfig()` with the argument of ``cfg`` to initialize the
27-
new configuration.
28-
29-
.. include:: /includes/fact-rs-conf-array-index.rst
30-
31-
If a member has :data:`~local.system.replset.members[n].priority` set
32-
to ``0``, it is ineligible to become :term:`primary` and will not seek
33-
election. :ref:`Hidden members <replica-set-hidden-members>`,
34-
:ref:`delayed members <replica-set-delayed-members>`, and
35-
:ref:`arbiters <replica-set-arbiters>` all have
7+
Overview
8+
--------
9+
10+
The priority settings of replica set members affect the outcomes
11+
of :doc:`elections </core/replica-set-elections>` for primary. Use this
12+
setting to ensure that some members are more likely to become primary and
13+
that others can never become primary.
14+
15+
The value of the member's
16+
:data:`~local.system.replset.members[n].priority` setting determines the
17+
member's priority in elections. The higher the number, the higher the
18+
priority.
19+
20+
Considerations
21+
--------------
22+
23+
To modify priorities, you update the :data:`~local.system.replset.members`
24+
array in the the replica configuration object. The array index begins with
25+
``0``. Do **not** confuse this index value with the value of the replica
26+
set member's :data:`~local.system.replset.members[n]._id` field in the
27+
array.
28+
29+
The value of :data:`~local.system.replset.members[n].priority` can be any
30+
floating point (i.e. decimal) number between ``0`` and ``1000``. The
31+
default value for the :data:`~local.system.replset.members[n].priority`
32+
field is ``1``.
33+
34+
To block a member from seeking election as primary, assign it a priority
35+
of ``0``. :ref:`Hidden members <replica-set-hidden-members>`,
36+
:ref:`delayed members <replica-set-delayed-members>`, and :ref:`arbiters
37+
<replica-set-arbiters>` all have
3638
:data:`~local.system.replset.members[n].priority` set to ``0``.
3739

38-
All members have a :data:`~local.system.replset.members[n].priority`
39-
equal to ``1`` by default.
40-
41-
The value of :data:`~local.system.replset.members[n].priority` can be
42-
any floating point (i.e. decimal) number between ``0`` and ``1000``.
43-
Priorities are only used to determine the preference in election. The
44-
priority value is used only in relation to other members. With the
45-
exception of members with a priority of ``0``, the absolute value of
46-
the :data:`~local.system.replset.members[n].priority` value is
47-
irrelevant.
48-
49-
Replica sets will preferentially elect and maintain the primary status
50-
of the member with the highest
51-
:data:`~local.system.replset.members[n].priority` setting.
52-
53-
.. warning::
54-
55-
Replica set reconfiguration can force the current primary to step
56-
down, leading to an election for primary in the replica
57-
set. Elections cause the current primary to close all open
58-
:term:`client` connections.
40+
Adjust priority during a sheduled maintenance window. Reconfiguring
41+
priority can force the current primary to step down, leading to an
42+
election. Before an election the primary closes all open :term:`client`
43+
connections.
5944

60-
Perform routine replica set reconfiguration during scheduled
61-
maintenance windows.
45+
Procedure
46+
---------
6247

63-
.. seealso:: The :ref:`Replica Reconfiguration Usage
64-
<replica-set-reconfiguration-usage>` example revolves around
65-
changing the priorities of the :data:`~local.system.replset.members`
66-
of a replica set.
48+
.. include:: /includes/steps/adjust-replica-set-member-priority.rst

0 commit comments

Comments
 (0)