Skip to content

Commit 9f7d3b3

Browse files
author
Bob Grabar
committed
DOCS-298 DOCS-299 migrate deploy shards
1 parent 1adb540 commit 9f7d3b3

File tree

3 files changed

+118
-126
lines changed

3 files changed

+118
-126
lines changed

source/administration/sharding.txt

Lines changed: 57 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Shard Cluster Administration
99

1010
This document describes common administrative tasks.
1111
For a full introduction to sharding in MongoDB see
12-
":doc:`/core/sharding`," and for a complete overview of all sharding
13-
documentation in the MongoDB Manual, see ":doc:`/sharding`." The
14-
":doc:`/administration/sharding-architectures`" document provides an
12+
:doc:`/core/sharding`, and for a complete overview of all sharding
13+
documentation in the MongoDB Manual, see :doc:`/sharding`. The
14+
:doc:`/administration/sharding-architectures` document provides an
1515
overview of deployment possibilities to help deploy a shard
16-
cluster. Finally, the ":doc:`/core/sharding-internals`" document
16+
cluster. Finally, the :doc:`/core/sharding-internals` document
1717
provides a more detailed introduction to sharding when troubleshooting
1818
issues or understanding your cluster's behavior.
1919

@@ -43,83 +43,63 @@ single server. For production, use the configurations described in
4343
scratch, see the :doc:`/tutorial/deploy-shard-cluster` tutorial for
4444
more detail or use the following procedure as a quick starting point:
4545

46-
1. Set up the required config servers, shards, and :program:`mongos`
47-
instances described in :ref:`Sharding Infrastructure
48-
<sharding-requirements-infrastructure>`.
46+
1. Create data directories for each of the three (3) config server instances.
4947

50-
51-
#. Start the three (3) config servers.
52-
53-
#. On all three config server instances, issue the following
54-
command to start the :program:`mongod` process:
48+
#. Start the three config server instances. For example, to start a
49+
config server instance running on TCP port ``27018`` with the data
50+
stored in ``/data/configdb``, type the following:
5551

5652
.. code-block:: sh
5753

58-
mongod --configsvr
54+
mongod --configsvr --dbpath /data/configdb --port 27018
5955

60-
This starts a :program:`mongod` instance running on TCP port
61-
``27018``, with the data stored in the ``/data/configdb`` path. All other
62-
:doc:`command line </reference/mongod>` and :doc:`configuration
63-
file </reference/configuration-options>` options are available for config
64-
server instances.
56+
For additional command options, see :doc:`/reference/mongod`
57+
and :doc:`/reference/configuration-options`.
6558

6659
.. include:: /includes/note-config-server-startup.rst
6760

68-
#. Start a :program:`mongos` instance issuing the following command:
69-
70-
.. code-block:: sh
61+
#. Start the three :program:`mongos` instances. For example, to start a
62+
:program:`mongos` instance running on the following hosts:
7163

72-
mongos --configdb config0.mongodb.example.net,config1.mongodb.example.net,config2.mongodb.example.net --port 27017
64+
- ``mongos0.example.net``
65+
- ``mongos1.example.net``
66+
- ``mongos2.example.net``
7367

74-
#. Connect to the :program:`mongos` instance using the :program:`mongo`
75-
shell.
68+
You would issue the following command:
7669

7770
.. code-block:: sh
7871

79-
mongo mongos.mongodb.example.net
80-
81-
#. Add shards to the cluster.
72+
mongos --configdb mongos0.example.net,mongos1.example.net,mongos2.example.net
8273

83-
Run the following commands while connected to a :program:`mongos` to
84-
initialize the cluster.
74+
#. Connect to one of the :program:`mongos` instances. For example, if
75+
a :program:`mongos` is accessible at ``mongos0.example.net`` on
76+
port ``27017``, issue the following command:
8577

86-
First, you need to tell the cluster where to find the individual
87-
shards. You can do this using the :dbcommand:`addShard` command.
78+
.. code-block:: sh
8879

89-
.. code-block:: javascript
80+
mongo mongos0.example.net
9081

91-
sh.addShard( "[hostname]:[port]" )
82+
#. Add shards to the cluster. From the :program:`mongo` shell connected
83+
to the :program:`mongos` instance, call the :method:`sh.addShard()`
84+
method for each shard to add to the cluster.
9285

9386
For example:
9487

9588
.. code-block:: javascript
9689

9790
sh.addShard( "mongodb0.example.net:27027" )
9891

99-
MongoDB will discover all other members of the replica set, if
100-
``mongodb0.example.net:27027`` is a member of a replica set.
92+
If ``mongodb0.example.net:27027`` is a member of a replica
93+
set, MongoDB will discover all other members of the replica set.
10194

10295
.. note:: In production deployments, all shards should be replica sets.
10396

10497
Repeat this step for each new shard in your cluster.
10598

10699
.. optional::
107100

108-
You may specify a "name" as an argument to the
109-
:dbcommand:`addShard`, as follows:
110-
111-
.. code-block:: javascript
112-
113-
db.runCommand( { addShard: mongodb0.example.net, name: "mongodb0" } )
114-
115-
Or:
116-
117-
.. code-block:: javascript
118-
119-
sh.addShard( mongodb0.example.net, name: "mongodb0" )
120-
121-
If you do not specify a shard name, then MongoDB will assign a
122-
name upon creation.
101+
You can specify a name for the shard and a maximum size. See
102+
:dbcommand:`addShard`.
123103

124104
.. note::
125105

@@ -139,25 +119,26 @@ single server. For production, use the configurations described in
139119

140120
sh.addShard( "repl0/mongodb0.example.net:27027,mongodb1.example.net:27017,mongodb2.example.net:27017" )
141121

142-
#. Enable sharding for any database that you want to shard.
122+
#. Enable sharding for each database you want to shard.
123+
While sharding operates on a per-collection basis, you must enable
124+
sharding for each database that holds collections you want to shard.
125+
This step is a meta-data change and will not redistribute your data.
143126

144-
MongoDB enables sharding on a per-database basis. This is only a
145-
meta-data change and will not redistribute your data. To enable
146-
sharding for a given database, use the :dbcommand:`enableSharding`
147-
command or the :method:`sh.enableSharding()` shell function.
127+
To enable sharding for a given database, use the
128+
:dbcommand:`enableSharding` command or the
129+
:method:`sh.enableSharding()` shell function, as shown below. Replace
130+
``<database>`` with the name of the database on which to enable
131+
sharding.
148132

149133
.. code-block:: javascript
150134

151-
db.runCommand( { enableSharding: [database] } )
135+
db.runCommand( { enableSharding: <database> } )
152136

153137
Or:
154138

155139
.. code-block:: javascript
156140

157-
sh.enableSharding([database])
158-
159-
Replace ``[database]`` with the name of the database you wish to
160-
enable sharding on.
141+
sh.enableSharding(<database>)
161142

162143
.. note::
163144

@@ -169,21 +150,21 @@ single server. For production, use the configurations described in
169150

170151
#. Enable sharding on a per-collection basis.
171152

172-
Finally, you must explicitly specify collections to shard. The
153+
Finally, you must explicitly specify collections to shard. The
173154
collections must belong to a database for which you have enabled
174155
sharding. When you shard a collection, you also choose the shard
175156
key. To shard a collection, run the :dbcommand:`shardCollection`
176157
command or the :method:`sh.shardCollection()` shell helper.
177158

178159
.. code-block:: javascript
179160

180-
db.runCommand( { shardCollection: "[database].[collection]", key: "[shard-key]" } )
161+
db.runCommand( { shardCollection: "<database>.<collection>", key: "<shard-key>" } )
181162

182163
Or:
183164

184165
.. code-block:: javascript
185166

186-
sh.shardCollection("[database].[collection]", "key")
167+
sh.shardCollection("<database>.<collection>", "key")
187168

188169
For example:
189170

@@ -218,6 +199,17 @@ This section describes common maintenance procedure, including: how to
218199
add and remove nodes, how to manually split chunks, and how to disable
219200
the balancer for backups.
220201

202+
List the Set of Configured Shards
203+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
204+
205+
To list the current set of configured shards and verify that all shards
206+
have been committed to the system, run the :dbcommand:`listShards`
207+
command:
208+
209+
.. code-block:: javascript
210+
211+
db.runCommand( { listshards : 1 } )
212+
221213
.. _sharding-procedure-add-shard:
222214

223215
Adding a Shard to a Cluster
@@ -235,9 +227,9 @@ procedure:
235227

236228
.. code-block:: javascript
237229

238-
sh.addShard( "[hostname]:[port]" )
230+
sh.addShard( "<hostname>:<port>" )
239231

240-
Replace ``[hostname]`` and ``[port]`` with the hostname and TCP
232+
Replace ``<hostname>`` and ``<port>`` with the hostname and TCP
241233
port number of where the shard is accessible.
242234

243235
For example:

source/reference/method/sh.addShard.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ sh.addShard()
88

99
:param host: Specify the hostname of a new shard server.
1010

11-
:param optional name: Specify the name of the new shard. If you do
12-
not specify a name for this shard, MongoDB
13-
will assign one by default.
14-
1511
Use this to add shard instances to the present :term:`shard
1612
cluster`. The ``host`` parameter can be in any of the following
1713
forms: ::

0 commit comments

Comments
 (0)