Skip to content

Commit f216652

Browse files
author
Sam Kleinman
committed
DOCS-93 editing tutorial and admin guide
1 parent 2912948 commit f216652

File tree

2 files changed

+71
-67
lines changed

2 files changed

+71
-67
lines changed

draft/administration/sharding.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,11 @@ The formal procedure for to remove a shard is as follows:
291291

292292
You must specify the name of the shard. You may have specified this
293293
shard name when you first ran the :dbcommand:`addShard` command. If not,
294-
you can find out the name of the shard by running the :dbcommand:`listshards`
295-
(or :func:`sh.status()` or :dbcommand:`printShardingStatus`) command.
294+
you can find out the name of the shard by running the
295+
:dbcommand:`listshards` or :dbcommand:`printShardingStatus`
296+
commands or the :func:`sh.status()` shell helper.
296297

297-
In the examples that follow, we'll assume we're removing a shard called ``mongodb0``.
298+
The examples that follow will remove a shard named ``mongodb0``.
298299

299300
#. Begin removing chunks from the shard.
300301

draft/tutorial/remove-shards-from-cluster.txt

Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Synopsis
88
This document describes the process for safely migrating data from a
99
shard so that you may decommission the systems that provide for the
1010
purpose of migration, or downsizing a cluster in response to actual
11-
use.
11+
use.
1212

1313
This process is only required if you need to migrate all data from an
1414
existing shard and decommission that shard. If you need to migrate an
@@ -19,7 +19,7 @@ migrate individual shards as if they were independent replica sets.
1919
.. mean time the above section will necessarily lack links.
2020

2121
The following list outlines the process for removing shards, from a
22-
high level:
22+
high level:
2323

2424
- Begin moving :term:`chunks` off of the shard.
2525

@@ -43,103 +43,106 @@ Procedure
4343
shell. See this section on :ref:`balancer operations
4444
<sharding-balancing-disable-temporally>` for more information.
4545

46-
The formal procedure for to remove a shard is as follows:
46+
Complete this procedure by connecting to any :program:`mongos` in the
47+
cluster using the :program:`mongo` shell.
4748

48-
#. Connect to any :program:`mongos` in the cluster using the
49-
:program:`mongo` shell.
49+
To remove a shard you must know it's name. If you specified a name
50+
when you added the shard using the :dbcommand:`addShard` command. If
51+
you did not specify a name at this point, MongoDB automatically
52+
assigned a name. You can discover or confirm the name of a shard using
53+
the :dbcommand:`listshards` or :dbcommand:`printShardingStatus`
54+
commands or the :func:`sh.status()` shell helper.
5055

51-
#. Determine the name of the shard you will be removing.
56+
The following examples will remove a shard named ``mongodb0``.
5257

53-
You must specify the name of the shard. You may have specified this
54-
shard name when you first ran the :dbcommand:`addShard` command. If not,
55-
you can find out the name of the shard by running the :dbcommand:`listshards`
56-
(or :func:`sh.status()` or :dbcommand:`printShardingStatus`) command.
58+
Remove Chunks from the Shard
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5760

58-
In the examples that follow, we'll assume we're removing a shard called ``mongodb0``.
61+
Start by running the :dbcommand:`removeShard` command. This
62+
begins "draining" chunks from the shard you''re removing.
5963

60-
#. Begin removing chunks from the shard.
64+
.. code-block:: javascript
6165

62-
Start by running the :dbcommand:`removeShard` command. This will
63-
start "draining" chunks from the shard you''re removing.
66+
db.runCommand( { removeshard: "mongodb0" } )
6467

65-
.. code-block:: javascript
68+
This operation will return the following response immediately:
6669

67-
db.runCommand( { removeshard: "mongodb0" } )
70+
.. code-block:: javascript
6871

69-
This operation will return the following response immediately:
72+
{ msg : "draining started successfully" , state: "started" , shard :"mongodb0" , ok : 1 }
7073

71-
.. code-block:: javascript
74+
Depending on your network capacity and the amount of data in your
75+
cluster, this operation can take anywhere from a few minutes to
76+
several days to complete.
7277

73-
{ msg : "draining started successfully" , state: "started" , shard :"mongodb0" , ok : 1 }
78+
Check the Status of the Migration
79+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7480

75-
Depending on your network capacity and the amount of data in your
76-
cluster, this operation can take anywhere from a few minutes to several
77-
days to complete.
81+
You can run the :dbcommand:`removeShard` again at any stage of the
82+
process to check the progress of the migration, as follows:
7883

79-
#. Check the progress of the migration.
84+
.. code-block:: javascript
8085

81-
You can run the :dbcommand:`removeShard` again at any stage of the
82-
process to check the progress of the migration, as follows:
86+
db.runCommand( { removeshard: "mongodb0" } )
8387

84-
.. code-block:: javascript
88+
The output will resemble the following document:
8589

86-
db.runCommand( { removeshard: "mongodb0" } )
90+
.. code-block:: javascript
8791

88-
The output should look something like this:
92+
{ msg: "draining ongoing" , state: "ongoing" , remaining: { chunks: 42, dbs : 1 }, ok: 1 }
8993

90-
.. code-block:: javascript
94+
In the ``remaining`` sub document, a counter displays the total number
95+
of chunks that MongoDB must migrate to other shards, and the number of
96+
MongoDB databases that have "primary" status on this shard.
9197

92-
{ msg: "draining ongoing" , �state: "ongoing" , remaining: { chunks: 42, dbs : 1 }, ok: 1 }
98+
Continue checking the status of the `removeshard` command until
99+
the number of chunks remaining is 0. Then you can proceed to the next step.
93100

94-
In the ``remaining`` sub document, a counter displays the
95-
total number of chunks that MongoDB must migrate to other shards,
96-
and the number of MongoDB databases that have "primary" status on
97-
this shard.
101+
Move Unsharded Databases
102+
~~~~~~~~~~~~~~~~~~~~~~~~
98103

99-
Continue checking the status of the `removeshard` command until
100-
the number of chunks remaining is 0. Then you can proceed to the next step.
104+
Databases with non-sharded collections store these collections on a
105+
single shard, known as the "primary" shard for that database. The
106+
following step is necessary only when the shard you want to remove is
107+
also the "primary" shard for one or more databases.
101108

102-
#. Move any databases to other shards in the cluster.
109+
Issue the following command at the :program:`mongo` shell:
103110

104-
Databases with non-sharded collections store these collections
105-
on a so-called "primary" shard. The following step is necessary
106-
only when the shard you want to remove is also the "primary" shard
107-
for one or more databases.
111+
.. code-block:: javascript
108112

109-
Issue the following command at the :program:`mongo` shell:
113+
db.runCommand( { movePrimary: "myapp", to: "mongodb1" })
110114

111-
.. code-block:: javascript
115+
This command will migrate all remaining non-sharded data in the
116+
database named ``myapp`` to the shard named ``mongodb1``.
112117

113-
db.runCommand( { movePrimary: "myapp", to: "mongodb1" })
118+
.. warning::
114119

115-
This command will migrate all remaining non-sharded data in the
116-
database named ``myapp`` to the shard named ``mongodb1``.
120+
Do not run the :dbcommand:`movePrimary` until you have *finished*
121+
draining the shard.
117122

118-
.. warning::
123+
This command can be long-running. It will not return until MongoDB
124+
completes moving all data. The response from this command will
125+
resemble the following:
119126

120-
Do not run the :dbcommand:`movePrimary` until you have *finished*
121-
draining the shard.
127+
.. code-block:: javascript
122128

123-
This command can be long-running. It will not return until MongoDB
124-
completes moving all data. The response from this command will
125-
resemble the following:
129+
{ "primary" : "mongodb1", "ok" : 1 }
126130

127-
.. code-block:: javascript
131+
Finalize the Migration
132+
~~~~~~~~~~~~~~~~~~~~~~
128133

129-
{ "primary" : "mongodb1", "ok" : 1 }
134+
Run :dbcommand:`removeShard` again to clean up all metadata
135+
information and finalize the removal, as follows:
130136

131-
#. Run :dbcommand:`removeShard` again to clean up all metadata
132-
information and finalize the removal, as follows:
137+
.. code-block:: javascript
133138

134-
.. code-block:: javascript
139+
db.runCommand( { removeshard: "mongodb0" } )
135140

136-
db.runCommand( { removeshard: "mongodb0" } )
141+
When successful, this command a document that resmbles the following:
137142

138-
When successful, this command will return a document like this:
143+
.. code-block:: javascript
139144

140-
.. code-block:: javascript
145+
{ msg: "remove shard completed succesfully" , stage: "completed", host: "mongodb0", ok : 1 }
141146

142-
{ msg: "remove shard completed succesfully" , stage: "completed", host: "mongodb0", ok : 1 }
143-
144-
Once the value if "state" is "completed", you may safely stop the processes
145-
comprising the ``mongodb0`` shard.
147+
Once the value if "state" is "completed", you may safely stop the
148+
processes that comprise the ``mongodb0`` shard.

0 commit comments

Comments
 (0)