Skip to content

Commit f4da886

Browse files
author
Sam Kleinman
committed
DOCS-2489: edits to removeShard command reference
1 parent b4e3a00 commit f4da886

File tree

1 file changed

+40
-22
lines changed

1 file changed

+40
-22
lines changed

source/reference/command/removeShard.txt

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,42 @@ removeShard
1010
:dbcommand:`removeShard`, MongoDB first moves the shard's chunks to
1111
other shards in the cluster. Then MongoDB removes the shard.
1212

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+
--------
1615

17-
The command takes the following form:
16+
Access Requirements
17+
~~~~~~~~~~~~~~~~~~~
1818

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.
2022

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.
2326

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+
-------
2638

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,
2849
with the following message:
2950

3051
.. code-block:: javascript
@@ -36,11 +57,12 @@ with the following message:
3657
"ok" : 1
3758
}
3859

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.
4263

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:
4466

4567
.. code-block:: javascript
4668

@@ -56,15 +78,11 @@ If you run the command again, you'll see the following progress output:
5678

5779
The ``remaining`` :term:`document` specifies how many chunks and databases
5880
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.
6583

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:
6886

6987
.. code-block:: javascript
7088

0 commit comments

Comments
 (0)