@@ -6,44 +6,71 @@ removeShard
6
6
7
7
.. dbcommand:: removeShard
8
8
9
- Starts the process of removing a shard from a :term:`cluster
10
- <sharded cluster>`. This
11
- is a multi-stage process. Begin by issuing the following command:
9
+ Removes a shard from a :term:`sharded cluster`. When you run
10
+ :dbcommand:`removeShard`, MongoDB first moves the shard's chunks to
11
+ other shards in the cluster. Then MongoDB removes the shard.
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.
16
+
17
+ The command takes the following form:
12
18
13
19
.. code-block:: javascript
14
20
15
- { removeShard : "[shardName]" }
21
+ use admin
22
+ db.runCommand( { removeShard : "<shardName>" } )
16
23
17
- The balancer will then migrate chunks from the shard specified by
18
- ``[shardName]``. This process happens slowly to avoid placing
19
- undue load on the overall cluster.
24
+ Behavior
25
+ --------
20
26
21
- The command returns immediately, with the following message:
27
+ When you run :dbcommand:`removeShard`, the command returns immediately,
28
+ with the following message:
22
29
23
- .. code-block:: javascript
30
+ .. code-block:: javascript
24
31
25
- { msg : "draining started successfully" , state: "started" , shard: "shardName" , ok : 1 }
32
+ {
33
+ "msg" : "draining started successfully",
34
+ "state" : "started",
35
+ "shard" : "bristol01",
36
+ "ok" : 1
37
+ }
26
38
27
- If you run the command again, you'll see the following progress
28
- output:
39
+ The balancer migrates chunks from shard ``bristol01``.
40
+ This process happens slowly to avoid placing undue load on the overall
41
+ cluster.
29
42
30
- .. code-block:: javascript
43
+ If you run the command again, you'll see the following progress output:
31
44
32
- { msg: "draining ongoing" , state: "ongoing" , remaining: { chunks: 23 , dbs: 1 }, ok: 1 }
45
+ .. code-block:: javascript
33
46
34
- The ``remaining`` :term:`document` specifies how many chunks and
35
- databases remain on the shard. Use :method:`db.printShardingStatus()`
36
- to list the databases that you must move from the shard.
47
+ {
48
+ "msg" : "draining ongoing",
49
+ "state" : "ongoing",
50
+ "remaining" : {
51
+ "chunks" : 23,
52
+ "dbs" : 1
53
+ },
54
+ "ok" : 1
55
+ }
37
56
38
- Each database in a sharded cluster has a primary shard. If the
39
- shard you want to remove is also the primary of one of the cluster's
40
- databases, then you must manually move the database to a new
41
- shard. This can be only after the shard is empty. See the
42
- :dbcommand:`movePrimary` command for details.
57
+ The ``remaining`` :term:`document` specifies how many chunks and databases
58
+ remain on the shard. Use :method:`db.printShardingStatus()` to list the
59
+ databases that you must move from the shard.
43
60
44
- After removing all chunks and databases from the shard, you
45
- may issue the command again, to return:
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.
46
65
47
- .. code-block:: javascript
66
+ After removing all chunks and databases from the shard, if you issue the
67
+ command again it returns:
68
+
69
+ .. code-block:: javascript
48
70
49
- { msg: "remove shard completed successfully", state: "completed", host: "shardName", ok : 1 }
71
+ {
72
+ "msg" : "removeshard completed successfully",
73
+ "state" : "completed",
74
+ "shard" : "bristol01",
75
+ "ok" : 1
76
+ }
0 commit comments