Skip to content

DOCS-2381 new steps format: adjust rs member priority #1562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 51 additions & 47 deletions source/tutorial/adjust-replica-set-member-priority.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,50 @@ Adjust Priority for Replica Set Member

.. default-domain:: mongodb

To change the value of the
:data:`~local.system.replset.members[n].priority` in the replica set
configuration, use the following sequence of commands in the
:program:`mongo` shell:
Overview
--------

Adjust the priority of a replica set member to change the member's
precedence in :doc:`elections </core/replica-set-elections>` for primary
or to prevent a member from becoming primary.

The number assigned to a member's
:data:`~local.system.replset.members[n].priority` field determines the
value of the field. The higher the number as compared to other
members in the set the higher the priority.

The value of :data:`~local.system.replset.members[n].priority` can be any
floating point (i.e. decimal) number between ``0`` and ``1000``. The
default value for the :data:`~local.system.replset.members[n].priority`
field is ``1``.

To block a member from seeking election as primary, assign it a priority
of ``0``. :ref:`Hidden members <replica-set-hidden-members>`,
:ref:`delayed members <replica-set-delayed-members>`, and :ref:`arbiters
<replica-set-arbiters>` all have
:data:`~local.system.replset.members[n].priority` set to ``0``.

Considerations
--------------

Adjust priority during scheduled maintenance windows.

Reconfiguring priority can force the current primary to step down, leading
to an election. Before an election the primary closes all open
:term:`client` connections.

To modify priorities, you update the :data:`~local.system.replset.members`
array in the the replica configuration object. The array index begins with
``0``. Do **not** confuse this index value with the value of the replica
set member's :data:`~local.system.replset.members[n]._id` field in the
array.

Procedure
---------

To change the :data:`~local.system.replset.members[n].priority` values in
the replica set configuration, use the following sequence of commands in
the :program:`mongo` shell:

.. code-block:: javascript

Expand All @@ -18,49 +58,13 @@ configuration, use the following sequence of commands in the
rs.reconfig(cfg)

The first operation uses :method:`rs.conf()` to set the local variable
``cfg`` to the contents of the current replica set configuration, which
is a :term:`document`. The next three operations change the
``cfg`` to the contents of the current replica set configuration, which is
a :term:`document`.

The next three operations change the
:data:`~local.system.replset.members[n].priority` value in the ``cfg``
document for the first three members configured in the :data:`members
<local.system.replset.members>` array. The final operation calls
:method:`rs.reconfig()` with the argument of ``cfg`` to initialize the
new configuration.

.. include:: /includes/fact-rs-conf-array-index.rst

If a member has :data:`~local.system.replset.members[n].priority` set
to ``0``, it is ineligible to become :term:`primary` and will not seek
election. :ref:`Hidden members <replica-set-hidden-members>`,
:ref:`delayed members <replica-set-delayed-members>`, and
:ref:`arbiters <replica-set-arbiters>` all have
:data:`~local.system.replset.members[n].priority` set to ``0``.

All members have a :data:`~local.system.replset.members[n].priority`
equal to ``1`` by default.

The value of :data:`~local.system.replset.members[n].priority` can be
any floating point (i.e. decimal) number between ``0`` and ``1000``.
Priorities are only used to determine the preference in election. The
priority value is used only in relation to other members. With the
exception of members with a priority of ``0``, the absolute value of
the :data:`~local.system.replset.members[n].priority` value is
irrelevant.

Replica sets will preferentially elect and maintain the primary status
of the member with the highest
:data:`~local.system.replset.members[n].priority` setting.

.. warning::

Replica set reconfiguration can force the current primary to step
down, leading to an election for primary in the replica
set. Elections cause the current primary to close all open
:term:`client` connections.

Perform routine replica set reconfiguration during scheduled
maintenance windows.
<local.system.replset.members>` array.

.. seealso:: The :ref:`Replica Reconfiguration Usage
<replica-set-reconfiguration-usage>` example revolves around
changing the priorities of the :data:`~local.system.replset.members`
of a replica set.
The final operation calls :method:`rs.reconfig()` with the argument of
``cfg`` to initialize the new configuration.