Skip to content

Commit c5fb9c0

Browse files
author
Andrew Leung
committed
added more content to the moveChunk command page.
1 parent 56230ee commit c5fb9c0

File tree

3 files changed

+66
-21
lines changed

3 files changed

+66
-21
lines changed

source/administration/sharding.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,17 +619,16 @@ In most circumstances, you should let the automatic balancer
619619
migrate :term:`chunks <chunk>` between :term:`shards <shard>`.
620620
However, you may want to migrate chunks manually in a few cases:
621621

622-
- If you create chunks by presplitting the data in your collection,
622+
- If you create chunks by :term:`pre-splitting` the data in your collection,
623623
you will have to migrate chunks manually to distribute chunks
624624
evenly across the shards.
625625

626626
- If the balancer in an active cluster cannot distribute chunks within
627627
the balancing window, then you will have to migrate chunks manually.
628628

629-
To further understand the chunk migration process in detail, see the
630-
:ref:`sharding-chunk-migration` section, and how to improve throughput
631-
for a shard cluster, see the
632-
:ref:`sharding-administration-create-chunks` section.
629+
See the :ref:`chunk migration <sharding-chunk-migration>` section to
630+
understand the internal process of how :term:`chunks <chunk>` move
631+
between :term:`shards <shard>`.
633632

634633
To migrate chunks, use the :dbcommand:`moveChunk` command.
635634

@@ -659,6 +658,10 @@ This command moves the chunk that includes the shard key value "smith" to the
659658
:term:`shard` named ``mongodb-shard3.example.net``. The command will
660659
block until the migration is complete.
661660

661+
See :ref:`create chunks <sharding-administration-create-chunks>` to
662+
understand how to use :term:`pre-splitting` to improve initial data
663+
load on a :term:`shard cluster`.
664+
662665
.. versionadded:: 2.2
663666
:dbcommand:`moveChunk` command has the: ``_secondaryThrottle``
664667
paramenter. When set to ``true``, MongoDB ensures that

source/faq/sharding.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ Consider the following error message:
342342
ERROR: moveChunk commit failed: version is at <n>|<nn> instead of <N>|<NN>" and "ERROR: TERMINATING"
343343

344344
:program:`mongod` procudes this message if, during a :ref:`chunk
345-
migration <sharding-chunk-migration>`, the term:`shard` could not
345+
migration <sharding-chunk-migration>`, the :term:`shard` could not
346346
connect to the :term:`config database` to update chunk information. If
347347
the shard cannot update the config database after
348348
:dbcommand:`moveChunk`, the shard cluster will have an inconsistent

source/reference/command/moveChunk.txt

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,64 @@ moveChunk
66

77
.. dbcommand:: moveChunk
88

9-
:dbcommand:`moveChunk` is an internal command that supports the
10-
sharding. Use the :method:`sh.moveChunk()` helper in the
11-
:program:`mongo` shell for manual chunk migrations.
9+
:dbcommand:`moveChunk` is an internal command that moves
10+
:term:`chunks <chunk>` between :term:`shards <shard>`. The command
11+
uses the following syntax:
12+
13+
.. code-block:: javascript
14+
15+
db.runCommand( { moveChunk : <namespace> ,
16+
find : <query> ,
17+
to : <destination>,
18+
<options> } )
19+
20+
:param moveChunk: the name of the :term:`collection` which the :term:`chunk`
21+
exists. The collection's full namespace must be given, including
22+
the database name, for example: ``"test.blog.posts"``
23+
24+
:param find: a query expression that specifies a document of the chunk
25+
to be moved, for example: ``{ author: "eliot" }``
26+
27+
:param to: the shard ID where the chunk will be moved to, for
28+
example: ``"shard1"``
29+
1230

1331
:option _secondaryThrottle: Set to ``false`` by default. Provides
14-
:ref:`write concern <write-concern>`
15-
support for chunk migrations.
16-
17-
If ``_secondaryThrottle`` is set to ``true``, during chunk
18-
migrations when a :term:`shard` hosted by a :term:`replica set`,
19-
the :program:`mongod` will wait until the :term:`secondary` members
20-
replicate the migration operations continuing to migrate chunk
21-
data. In the balancer configuration, the ``replThrottle``
22-
configuration provides ``_secondaryThrottle`` behavior.
23-
24-
For details on chunk migrations see the :ref:`Chunk Migration
25-
<sharding-chunk-migration>` section.
32+
:ref:`write concern <write-concern>` support for chunk
33+
migrations.
34+
35+
If ``_secondaryThrottle`` is set to ``true``, during chunk
36+
migrations when a :term:`shard` hosted by a :term:`replica set`,
37+
the :program:`mongod` will wait until the :term:`secondary`
38+
members replicate the migration operations continuing to migrate
39+
chunk data. In the balancer configuration, the ``replThrottle``
40+
configuration provides ``_secondaryThrottle`` behavior.
41+
42+
Use the :method:`sh.moveChunk()` helper in the :program:`mongo`
43+
shell for manual chunk migrations.
44+
45+
For details on how chunks move within MongoDB see the :ref:`chunk
46+
migration <sharding-chunk-migration>` section.
47+
48+
:dbcommand:`moveChunk` will return the following ``errmsg`` if the
49+
:term:`chunk` to be moved is in use by another :term:`cursor`:
50+
51+
.. code-block:: none
52+
53+
The collection's metadata lock is already taken.
54+
55+
These errors usually occur when there are too many open
56+
:term:`cursors <cursor>` accessing the chunk you are migrating. You
57+
can either wait until the cursors complete their operation or close
58+
the cursors manually.
59+
60+
.. note::
61+
62+
This command should not be used except in special circumstances
63+
such as preparing your :term:`shard cluster` for an initial
64+
ingest of data.
65+
66+
.. seealso:: ":ref:`Create chunk <sharding-administration-create-chunks>`"
67+
2668

2769
.. admin-only

0 commit comments

Comments
 (0)