@@ -221,11 +221,10 @@ Configuration Variables
221
221
Example Document
222
222
----------------
223
223
224
- The following document is a prototypical representation a MongoDB
225
- replica set configuration document. Square brackets (e.g. ``[`` and
224
+ the following document is a prototypical representation a mongodb
225
+ replica set configuration document. square brackets (e.g. ``[`` and
226
226
``]``) enclose all optional fields.
227
227
228
-
229
228
.. code-block:: javascript
230
229
231
230
{
@@ -234,53 +233,108 @@ replica set configuration document. Square brackets (e.g. ``[`` and
234
233
{
235
234
_id : <ordinal>,
236
235
host : <hostname[:port]>
237
- [, arbiterOnly : true]
238
- [, buildIndexes : <bool>]
236
+ [, arbiteronly : true]
237
+ [, buildindexes : <bool>]
239
238
[, hidden : true]
240
239
[, priority: <priority>]
241
- [, tags: {loc1 : desc1, loc2 : desc2, ..., locN : descN }]
242
- [, slaveDelay : <n>]
240
+ [, tags: {loc1 : desc1, loc2 : desc2, ..., locn : descn }]
241
+ [, slavedelay : <n>]
243
242
[, votes : <n>]
244
243
}
245
244
, ...
246
245
],
247
246
[settings: {
248
- [getLastErrorDefaults : <lasterrdefaults>]
249
- [, getLastErrorModes : <modes>]
247
+ [getlasterrordefaults : <lasterrdefaults>]
248
+ [, getlasterrormodes : <modes>]
250
249
}]
251
250
}
252
251
253
252
.. _replica-set-reconfiguration-usage:
254
253
255
- Use
254
+ use
256
255
---
257
256
258
- Most modifications of replica set configuration use the
259
- :program:`mongo` shell. Consider the following example:
257
+ most modifications of replica set configuration use the
258
+ :program:`mongo` shell. consider the following:
259
+
260
+ .. example::
261
+
262
+ Given the following replica set configuration:
263
+
264
+ .. code-block:: javascript
265
+
266
+ {
267
+ "_id" : "rs0",
268
+ "version" : 1,
269
+ "members" : [
270
+ {
271
+ "_id" : 0,
272
+ "host" : "mongodb0.example.net:27017",
273
+ },
274
+ {
275
+ "_id" : 1,
276
+ "host" : "mongodb1.example.net:27017"
277
+ },
278
+ {
279
+ "_id" : 2,
280
+ "host" : "mongodb2.example.net:27017",
281
+ }
282
+ ]
283
+ }
284
+
285
+ And the following reconfiguration operation:
286
+
287
+ .. code-block:: javascript
288
+
289
+ cfg = rs.conf()
290
+ cfg.members[0].priority = 0.5
291
+ cfg.members[1].priority = 2
292
+ cfg.members[2].priority = 2
293
+ rs.reconfig(cfg)
294
+
295
+ This operation begins by saving the current replica set
296
+ configuration to the local variable ``cfg`` using the
297
+ :func:`rs.conf()` method. Then it adds priority values to the
298
+ :term:`document` where the :data:`members[n]._id` field has a value
299
+ of ``0``, ``1``, or ``2``. Finally, it calls the
300
+ :func:`rs.reconfig()` method with the argument of ``cfg`` to
301
+ initialize this new configuration. The replica set configuration
302
+ after this operation will resemble the following:
303
+
304
+ .. code-block:: javascript
305
+
306
+ {
307
+ "_id" : "rs0",
308
+ "version" : 1,
309
+ "members" : [
310
+ {
311
+ "_id" : 0,
312
+ "host" : "mongodb0.example.net:27017",
313
+ "priority" : 0.5
314
+ },
315
+ {
316
+ "_id" : 1,
317
+ "host" : "mongodb1.example.net:27017"
318
+ "priority" : 2
319
+ },
320
+ {
321
+ "_id" : 2,
322
+ "host" : "mongodb2.example.net:27017",
323
+ "priority" : 1
324
+ }
325
+ ]
326
+ }
260
327
261
- .. code-block:: javascript
262
328
263
- cfg = rs.conf()
264
- cfg.members[0].priority = 0.5
265
- cfg.members[1].priority = 2
266
- cfg.members[2].priority = 2
267
- rs.reconfig(cfg)
268
-
269
- This operation begins by saving the current replica set configuration
270
- to the local variable ``cfg`` using the :func:`rs.conf()`
271
- method. Then it adds priority values to the :term:`document`
272
- where the :data:`members[n]._id` field has a value of ``0``, ``1``, or
273
- ``2``. Finally, it calls the :func:`rs.reconfig()` method with the
274
- argument of ``cfg`` to initialize this new configuration.
275
-
276
- Using this "dot notation," you can modify any existing setting or
277
- specify any of optional :ref:`replica set configuration variables
329
+ Using the "dot notation" demonstrated in the above example, you can
330
+ modify any existing setting or specify any of optional :ref:`replica
331
+ set configuration variables
278
332
<replica-set-configuration-variables>`. Until you run
279
333
``rs.reconfig(cfg)`` at the shell, no changes will take effect. You
280
334
can issue ``cfg = rs.conf()`` at any time before using
281
- :func:`rs.reconfig()` to undo your changes and start from the
282
- current configuration. If you issue ``cfg`` as an operation at any
283
- point, the :program:`mongo` shell at any point will output the complete
335
+ :func:`rs.reconfig()` to undo your changes and start from the current
336
+ configuration. If you issue ``cfg`` as an operation at any point, the
337
+ :program:`mongo` shell at any point will output the complete
284
338
:term:`document` with modifications for your review.
285
339
286
340
The :func:`rs.reconfig()` operation has a "force" option, to make it
0 commit comments