|
1 | 1 | title: Copy the replica set configuration to a variable.
|
2 | 2 | stepnum: 1
|
3 | 3 | ref: copy-configration-object
|
| 4 | +pre: | |
| 5 | + In the :program:`mongo` shell, use :method:`rs.conf()` to retrieve |
| 6 | + the replica set configuration and assign it to a variable. For |
| 7 | + example: |
4 | 8 | 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() |
| 9 | + language: javascript |
| 10 | + code: | |
| 11 | + cfg = rs.conf() |
12 | 12 | ---
|
13 | 13 | title: Change each member's priority value.
|
14 | 14 | stepnum: 2
|
15 | 15 | ref: change-priority-values
|
| 16 | +pre: | |
| 17 | + Change each member's :data:`~local.system.replset.members[n].priority` |
| 18 | + value, as configured in the :data:`~local.system.replset.members` |
| 19 | + array. |
16 | 20 | 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. |
| 21 | + language: javascript |
| 22 | + code: | |
| 23 | + cfg.members[0].priority = 0.5 |
| 24 | + cfg.members[1].priority = 2 |
| 25 | + cfg.members[2].priority = 2 |
22 | 26 | 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 |
| 27 | + This sequence of operations modifies the value of ``cfg`` to set the |
| 28 | + priority for the first three members defined in the |
| 29 | + :data:`~local.system.replset.members` array. |
30 | 30 | ---
|
31 | 31 | title: Assign the replica set the new configuration.
|
32 | 32 | stepnum: 3
|
33 | 33 | ref: assign-new-config
|
| 34 | +pre: | |
| 35 | + Use :method:`rs.reconfig()` to apply the new configuration. |
34 | 36 | action:
|
35 |
| - - pre: | |
36 |
| - Use :method:`rs.reconfig()` to apply the new configuration. |
| 37 | + language: javascript |
| 38 | + code: | |
| 39 | + rs.reconfig(cfg) |
37 | 40 | 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) |
| 41 | + This operation updates the configuration of the replica set using |
| 42 | + the configuration defined by the value of ``cfg``. |
43 | 43 | ...
|
0 commit comments