@@ -8,14 +8,7 @@ Sharded Cluster Administration
8
8
.. default-domain:: mongodb
9
9
10
10
This document describes common administrative tasks for sharded
11
- clusters. For a full introduction to sharding in MongoDB see
12
- :doc:`/core/sharding`, and for a complete overview of all sharding
13
- documentation in the MongoDB Manual, see :doc:`/sharding`. The
14
- :doc:`/administration/sharding-architectures` document provides an
15
- overview of deployment possibilities to help deploy a sharded
16
- cluster. Finally, the :doc:`/core/sharding-internals` document
17
- provides a more detailed introduction to sharding when troubleshooting
18
- issues or understanding your cluster's behavior.
11
+ clusters. For a list of all sharding documentation see :doc:`/sharding`.
19
12
20
13
.. contents:: Sharding Procedures:
21
14
:backlinks: none
@@ -26,8 +19,7 @@ issues or understanding your cluster's behavior.
26
19
Set up a Sharded Cluster
27
20
------------------------
28
21
29
- Before deploying a cluster, see the requirements listed in
30
- :ref:`Requirements for Sharded Clusters <sharding-requirements>`.
22
+ Before deploying a cluster, see :ref:`sharding-requirements`.
31
23
32
24
For testing purposes, you can run all the required shard :program:`mongod` processes on a
33
25
single server. For production, use the configurations described in
@@ -198,99 +190,8 @@ use the following procedure as a quick starting point:
198
190
Cluster Management
199
191
------------------
200
192
201
- Once you have a running sharded cluster, you will need to maintain it.
202
- This section describes common maintenance procedure, including: how to
203
- add and remove shards, how to manually split chunks, and how to disable
204
- the balancer for backups.
205
-
206
- List Databases with Sharding Enabled
207
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208
-
209
- To list the databases for which sharding is enabled, query the
210
- ``databases`` collection in the :ref:`config database
211
- <config-database>`. The databases with the ``partitioned`` field set to
212
- ``true`` have sharding enabled.
213
-
214
- .. example:: Run this sequence of commands to open the :ref:`config
215
- database <config-database>` and query the ``databases`` collection.
216
-
217
- .. code-block:: javascript
218
-
219
- use config
220
- db.databases.find()
221
-
222
- Given the following example output:
223
-
224
- .. code-block:: javascript
225
-
226
- { "_id" : "admin", "partitioned" : false, "primary" : "config" }
227
- { "_id" : "foo", "partitioned" : true, "primary" : "example1.com:30001" }
228
- { "_id" : "baz", "partitioned" : false, "primary" : "example2.com:27017" }
229
-
230
- Only the database `foo` has sharding enabled because only `foo` has
231
- the ``partitioned`` field set to ``true``.
232
-
233
- List Shards
234
- ~~~~~~~~~~~
235
-
236
- To list the current set of configured shards and verify that all shards
237
- have been committed to the system, run the :dbcommand:`listShards`
238
- command:
239
-
240
- .. code-block:: javascript
241
-
242
- db.runCommand( { listshards : 1 } )
243
-
244
- View Cluster Details
245
- ~~~~~~~~~~~~~~~~~~~~
246
-
247
- To view cluster details, issue :method:`db.printShardingStatus()` or
248
- :method:`sh.status()`. Both methods return the same output.
249
-
250
- .. example:: In the following example output from :method:`sh.status()`
251
-
252
- - ``sharding version`` displays the version number of the shard
253
- metadata.
254
-
255
- - ``shards`` displays each :program:`mongod` instance that is used as
256
- a shard.
257
-
258
- - ``databases`` displays all databases living in the cluster,
259
- including databases for which sharding is not enabled.
260
-
261
- - The ``chunks`` information for the ``foo`` database displays how
262
- many chunks are on each shard and displays the range of each chunk.
263
-
264
- .. code-block:: javascript
265
-
266
- --- Sharding Status ---
267
- sharding version: { "_id" : 1, "version" : 3 }
268
- shards:
269
- { "_id" : "shard0000", "host" : "example1.com:40000" }
270
- { "_id" : "shard0001", "host" : "example2.com:50000" }
271
- databases:
272
- { "_id" : "admin", "partitioned" : false, "primary" : "config" }
273
- { "_id" : "foo", "partitioned" : true, "primary" : "shard0000" }
274
- foo.big chunks:
275
- shard0001 1
276
- shard0000 6
277
- { "a" : { $minKey : 1 } } -->> { "a" : "elephant" } on : shard0001 Timestamp(2000, 1) jumbo
278
- { "a" : "elephant" } -->> { "a" : "giraffe" } on : shard0000 Timestamp(1000, 1) jumbo
279
- { "a" : "giraffe" } -->> { "a" : "hippopotamus" } on : shard0000 Timestamp(2000, 2) jumbo
280
- { "a" : "hippopotamus" } -->> { "a" : "lion" } on : shard0000 Timestamp(2000, 3) jumbo
281
- { "a" : "lion" } -->> { "a" : "rhinoceros" } on : shard0000 Timestamp(1000, 3) jumbo
282
- { "a" : "rhinoceros" } -->> { "a" : "springbok" } on : shard0000 Timestamp(1000, 4)
283
- { "a" : "springbok" } -->> { "a" : { $maxKey : 1 } } on : shard0000 Timestamp(1000, 5)
284
- foo.large chunks:
285
- shard0001 1
286
- shard0000 5
287
- { "a" : { $minKey : 1 } } -->> { "a" : "hen" } on : shard0001 Timestamp(2000, 0)
288
- { "a" : "hen" } -->> { "a" : "horse" } on : shard0000 Timestamp(1000, 1) jumbo
289
- { "a" : "horse" } -->> { "a" : "owl" } on : shard0000 Timestamp(1000, 2) jumbo
290
- { "a" : "owl" } -->> { "a" : "rooster" } on : shard0000 Timestamp(1000, 3) jumbo
291
- { "a" : "rooster" } -->> { "a" : "sheep" } on : shard0000 Timestamp(1000, 4)
292
- { "a" : "sheep" } -->> { "a" : { $maxKey : 1 } } on : shard0000 Timestamp(1000, 5)
293
- { "_id" : "test", "partitioned" : false, "primary" : "shard0000" }
193
+ This section describes how to add and remove shards and how to view
194
+ information about your :term:`sharded cluster`.
294
195
295
196
.. _sharding-procedure-add-shard:
296
197
@@ -359,9 +260,8 @@ procedure:
359
260
It may take some time for :term:`chunks <chunk>` to migrate to the
360
261
new shard.
361
262
362
- See the :ref:`Balancing and Distribution <sharding-balancing>`
363
- section for an overview of the balancing operation and the :ref:`Balancing Internals
364
- <sharding-balancing-internals>` section for additional information.
263
+ For an introduction to balancing, see :ref:`sharding-balancing`. For
264
+ lower level information on balancing, see :ref:`sharding-balancing-internals`.
365
265
366
266
.. _sharding-procedure-remove-shard:
367
267
@@ -483,6 +383,95 @@ The procedure to remove a shard is as follows:
483
383
Once the value of the ``stage`` field is "completed," you may safely
484
384
stop the processes comprising the ``mongodb0`` shard.
485
385
386
+ List Databases with Sharding Enabled
387
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
388
+
389
+ To list the databases for which sharding is enabled, query the
390
+ ``databases`` collection in the :ref:`config-database`.
391
+ The databases with the ``partitioned`` field set to
392
+ ``true`` have sharding enabled.
393
+
394
+ .. example:: Run this sequence of commands to open the :ref:`config
395
+ database <config-database>` and query the ``databases`` collection.
396
+
397
+ .. code-block:: javascript
398
+
399
+ use config
400
+ db.databases.find()
401
+
402
+ Given the following example output:
403
+
404
+ .. code-block:: javascript
405
+
406
+ { "_id" : "admin", "partitioned" : false, "primary" : "config" }
407
+ { "_id" : "foo", "partitioned" : true, "primary" : "example1.com:30001" }
408
+ { "_id" : "baz", "partitioned" : false, "primary" : "example2.com:27017" }
409
+
410
+ Only the database `foo` has sharding enabled because only `foo` has
411
+ the ``partitioned`` field set to ``true``.
412
+
413
+ List Shards
414
+ ~~~~~~~~~~~
415
+
416
+ To list the current set of configured shards and verify that all shards
417
+ have been committed to the system, run the :dbcommand:`listShards`
418
+ command:
419
+
420
+ .. code-block:: javascript
421
+
422
+ db.runCommand( { listshards : 1 } )
423
+
424
+ View Cluster Details
425
+ ~~~~~~~~~~~~~~~~~~~~
426
+
427
+ To view cluster details, issue :method:`db.printShardingStatus()` or
428
+ :method:`sh.status()`. Both methods return the same output.
429
+
430
+ .. example:: In the following example output from :method:`sh.status()`
431
+
432
+ - ``sharding version`` displays the version number of the shard
433
+ metadata.
434
+
435
+ - ``shards`` displays each :program:`mongod` instance that is used as
436
+ a shard.
437
+
438
+ - ``databases`` displays all databases living in the cluster,
439
+ including databases for which sharding is not enabled.
440
+
441
+ - The ``chunks`` information for the ``foo`` database displays how
442
+ many chunks are on each shard and displays the range of each chunk.
443
+
444
+ .. code-block:: javascript
445
+
446
+ --- Sharding Status ---
447
+ sharding version: { "_id" : 1, "version" : 3 }
448
+ shards:
449
+ { "_id" : "shard0000", "host" : "example1.com:40000" }
450
+ { "_id" : "shard0001", "host" : "example2.com:50000" }
451
+ databases:
452
+ { "_id" : "admin", "partitioned" : false, "primary" : "config" }
453
+ { "_id" : "foo", "partitioned" : true, "primary" : "shard0000" }
454
+ foo.big chunks:
455
+ shard0001 1
456
+ shard0000 6
457
+ { "a" : { $minKey : 1 } } -->> { "a" : "elephant" } on : shard0001 Timestamp(2000, 1) jumbo
458
+ { "a" : "elephant" } -->> { "a" : "giraffe" } on : shard0000 Timestamp(1000, 1) jumbo
459
+ { "a" : "giraffe" } -->> { "a" : "hippopotamus" } on : shard0000 Timestamp(2000, 2) jumbo
460
+ { "a" : "hippopotamus" } -->> { "a" : "lion" } on : shard0000 Timestamp(2000, 3) jumbo
461
+ { "a" : "lion" } -->> { "a" : "rhinoceros" } on : shard0000 Timestamp(1000, 3) jumbo
462
+ { "a" : "rhinoceros" } -->> { "a" : "springbok" } on : shard0000 Timestamp(1000, 4)
463
+ { "a" : "springbok" } -->> { "a" : { $maxKey : 1 } } on : shard0000 Timestamp(1000, 5)
464
+ foo.large chunks:
465
+ shard0001 1
466
+ shard0000 5
467
+ { "a" : { $minKey : 1 } } -->> { "a" : "hen" } on : shard0001 Timestamp(2000, 0)
468
+ { "a" : "hen" } -->> { "a" : "horse" } on : shard0000 Timestamp(1000, 1) jumbo
469
+ { "a" : "horse" } -->> { "a" : "owl" } on : shard0000 Timestamp(1000, 2) jumbo
470
+ { "a" : "owl" } -->> { "a" : "rooster" } on : shard0000 Timestamp(1000, 3) jumbo
471
+ { "a" : "rooster" } -->> { "a" : "sheep" } on : shard0000 Timestamp(1000, 4)
472
+ { "a" : "sheep" } -->> { "a" : { $maxKey : 1 } } on : shard0000 Timestamp(1000, 5)
473
+ { "_id" : "test", "partitioned" : false, "primary" : "shard0000" }
474
+
486
475
Chunk Management
487
476
----------------
488
477
@@ -635,7 +624,9 @@ To create and migrate chunks manually, use the following procedure:
635
624
}
636
625
637
626
You can also let the balancer automatically distribute the new
638
- chunks.
627
+ chunks. For an introduction to balancing, see
628
+ :ref:`sharding-balancing`. For lower level information on balancing,
629
+ see :ref:`sharding-balancing-internals`.
639
630
640
631
.. _sharding-balancing-modify-chunk-size:
641
632
@@ -654,7 +645,7 @@ To modify the chunk size, use the following procedure:
654
645
#. Connect to any :program:`mongos` in the cluster using the
655
646
:program:`mongo` shell.
656
647
657
- #. Issue the following command to switch to the config database:
648
+ #. Issue the following command to switch to the :ref:` config- database` :
658
649
659
650
.. code-block:: javascript
660
651
@@ -710,9 +701,9 @@ However, you may want to migrate chunks manually in a few cases:
710
701
- If the balancer in an active cluster cannot distribute chunks within
711
702
the balancing window, then you will have to migrate chunks manually.
712
703
713
- See the :ref:`chunk migration <sharding-chunk-migration>` section to
714
- understand the internal process of how chunks move
715
- between shards .
704
+ For more information on how chunks move between shards, see
705
+ :ref:`sharding-balancing-internals`, in particular the section
706
+ :ref:`sharding-chunk-migration` .
716
707
717
708
To migrate chunks, use the :dbcommand:`moveChunk` command.
718
709
@@ -773,12 +764,10 @@ to pre-splitting.
773
764
Balancer Operations
774
765
-------------------
775
766
776
- This section provides an overview of common administrative procedures
777
- related to balancing and the balancing process.
778
-
779
- .. seealso:: :ref:`sharding-balancing` and the
780
- :dbcommand:`moveChunk` that provides manual :term:`chunk`
781
- migrations.
767
+ This section describes provides common administrative procedures related
768
+ to balancing. For an introduction to balancing, see
769
+ :ref:`sharding-balancing`. For lower level information on balancing, see
770
+ :ref:`sharding-balancing-internals`.
782
771
783
772
.. _sharding-balancing-check-lock:
784
773
@@ -791,7 +780,7 @@ To see if the balancer process is active in your :term:`cluster
791
780
#. Connect to any :program:`mongos` in the cluster using the
792
781
:program:`mongo` shell.
793
782
794
- #. Issue the following command to switch to the config database:
783
+ #. Issue the following command to switch to the :ref:` config- database` :
795
784
796
785
.. code-block:: javascript
797
786
@@ -856,7 +845,7 @@ be able to migrate chunks:
856
845
#. Connect to any :program:`mongos` in the cluster using the
857
846
:program:`mongo` shell.
858
847
859
- #. Issue the following command to switch to the config database:
848
+ #. Issue the following command to switch to the :ref:` config- database` :
860
849
861
850
.. code-block:: javascript
862
851
@@ -942,7 +931,7 @@ run this operation from a driver that does not have helper functions:
942
931
#. Connect to any :program:`mongos` in the cluster using the
943
932
:program:`mongo` shell.
944
933
945
- #. Issue the following command to switch to the config database:
934
+ #. Issue the following command to switch to the :ref:` config- database` :
946
935
947
936
.. code-block:: javascript
948
937
@@ -1000,7 +989,7 @@ three config servers.
1000
989
#. Copy the entire :setting:`dbpath` file system tree from the
1001
990
existing config server to the two machines that will provide the
1002
991
additional config servers. These commands, issued on the system
1003
- with the existing config database, ``mongo-config0.example.net`` may
992
+ with the existing :ref:` config- database` , ``mongo-config0.example.net`` may
1004
993
resemble the following:
1005
994
1006
995
.. code-block:: sh
@@ -1062,7 +1051,7 @@ as needed.
1062
1051
Migrate Config Servers with Different Hostnames
1063
1052
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1064
1053
1065
- Use this process when you need to migrate a config database to a new
1054
+ Use this process when you need to migrate a :ref:` config- database` to a new
1066
1055
server and it *will not* be accessible via the same hostname. If
1067
1056
possible, avoid changing the hostname so that you can use the
1068
1057
:ref:`previous procedure <sharding-process-config-server-migrate-same-hostname>`.
@@ -1088,7 +1077,7 @@ possible, avoid changing the hostname so that you can use the
1088
1077
that provide your shards.
1089
1078
1090
1079
- the :program:`mongod` instances that provide your existing
1091
- config databases.
1080
+ :ref:` config databases <config-database>` .
1092
1081
1093
1082
- all :program:`mongos` instances in your cluster.
1094
1083
@@ -1139,7 +1128,7 @@ Backup Cluster Metadata
1139
1128
~~~~~~~~~~~~~~~~~~~~~~~
1140
1129
1141
1130
The cluster will remain operational [#read-only]_ without one
1142
- of the config databases :program:`mongod` instances, creating a backup
1131
+ of the config database's :program:`mongod` instances, creating a backup
1143
1132
of the cluster metadata from the config database is straight forward:
1144
1133
1145
1134
#. Shut down one of the :term:`config databases <config database>`.
0 commit comments