/
replSetStepDown.txt
84 lines (50 loc) · 1.93 KB
/
replSetStepDown.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
===============
replSetStepDown
===============
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Description
-----------
.. dbcommand:: replSetStepDown
Forces the :term:`primary` of the replica set to become a
:term:`secondary`. This initiates an :ref:`election for primary
<replica-set-election-internals>`.
:dbcommand:`replSetStepDown` has the following prototype form:
.. code-block:: javascript
db.runCommand( { replSetStepDown: <seconds> , force: <true|false> } )
:dbcommand:`replSetStepDown` has the following fields:
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Field
- Type
- Description
* - ``replSetStepDown``
- number
- Optional. A number of seconds for the member to avoid election to primary. If you
do not specify a value for ``<seconds>``, :dbcommand:`replSetStepDown`
will attempt to avoid reelection to primary for 60 seconds.
* - ``force``
- Boolean
- Optional. New in version 2.0: Forces the :term:`primary` to step down even if
there are no secondary members within 10 seconds of the primary's
latest optime.
.. warning:: :dbcommand:`replSetStepDown` forces all clients
currently connected to the database to disconnect. This helps
ensure that clients maintain an accurate view of the replica
set.
.. versionadded:: 2.0
If there is no :term:`secondary` within 10 seconds of the
primary, :dbcommand:`replSetStepDown` will not succeed to
prevent long running elections.
Example
-------
The following example specifies that the former primary avoids
reelection to primary for 120 seconds:
.. code-block:: javascript
db.runCommand( { replSetStepDown: 120 } )
.. slave-ok, admin-only