@@ -10,21 +10,42 @@ removeShard
10
10
:dbcommand:`removeShard`, MongoDB first moves the shard's chunks to
11
11
other shards in the cluster. Then MongoDB removes the shard.
12
12
13
- To run the command you must have administrative access. Either run
14
- :dbcommand:`removeShard` from the admin database or run it with the
15
- :method:`sh._adminCommand` command.
13
+ Behavior
14
+ --------
16
15
17
- The command takes the following form:
16
+ Access Requirements
17
+ ~~~~~~~~~~~~~~~~~~~
18
18
19
- .. code-block:: javascript
19
+ You *must* run :dbcommand:`removeShard` while connected to a
20
+ :program:`mongos`. Issue the command against the ``admin`` database or
21
+ use the :method:`sh._adminCommand()` helper.
20
22
21
- use admin
22
- db.runCommand( { removeShard : "<shardName>" } )
23
+ If you have :setting:`auth` enabled, you must have the
24
+ :authrole:`clusterManager` role or any role that
25
+ includes the :authaction:`removeShard` action.
23
26
24
- Behavior
25
- --------
27
+ Database Migration Requirements
28
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29
+
30
+ Each database in a sharded cluster has a primary shard. If the shard you
31
+ want to remove is also the primary of one of the cluster's databases, then
32
+ you must manually move the databases to a new shard after migrating
33
+ all data from the shard. See the :dbcommand:`movePrimary` command and
34
+ the :doc:`/tutorial/remove-shards-from-cluster` for more information.
35
+
36
+ Example
37
+ -------
26
38
27
- When you run :dbcommand:`removeShard`, the command returns immediately,
39
+ From the :program:`mongo` shell, the :dbcommand:`removeShard`
40
+ operation resembles the following:
41
+
42
+ .. code-block:: javascript
43
+
44
+ use admin
45
+ db.runCommand( { removeShard : "bristol01" } )
46
+
47
+ Replace ``bristol01`` with the name of the shard to remove. When you
48
+ run :dbcommand:`removeShard`, the command returns immediately,
28
49
with the following message:
29
50
30
51
.. code-block:: javascript
@@ -36,11 +57,12 @@ with the following message:
36
57
"ok" : 1
37
58
}
38
59
39
- The balancer migrates chunks from shard ``bristol01``.
40
- This process happens slowly to avoid placing undue load on the overall
41
- cluster.
60
+ The balancer begins migrating chunks from the shard named
61
+ ``bristol01`` to other shards in the cluster. These migrations happens
62
+ slowly to avoid placing undue load on the overall cluster.
42
63
43
- If you run the command again, you'll see the following progress output:
64
+ If you run the command again, :dbcommand:`removeShard` returns the
65
+ following progress output:
44
66
45
67
.. code-block:: javascript
46
68
@@ -56,15 +78,11 @@ If you run the command again, you'll see the following progress output:
56
78
57
79
The ``remaining`` :term:`document` specifies how many chunks and databases
58
80
remain on the shard. Use :method:`db.printShardingStatus()` to list the
59
- databases that you must move from the shard.
60
-
61
- Each database in a sharded cluster has a primary shard. If the shard you
62
- want to remove is also the primary of one of the cluster's databases, then
63
- you must manually move the database to a new shard. This can be done only
64
- after the shard is empty. See the :dbcommand:`movePrimary` command for details.
81
+ databases that you must move from the shard. Use the
82
+ :dbcommand:`movePrimary` to move databases.
65
83
66
- After removing all chunks and databases from the shard, if you issue the
67
- command again it returns :
84
+ After removing all chunks and databases from the shard, you can issue
85
+ :dbcommand:`removeShard` again see the following :
68
86
69
87
.. code-block:: javascript
70
88
0 commit comments