Skip to content

Commit ff72e49

Browse files
author
Sam Kleinman
committed
merge: DOCS-865
2 parents fbbd1c8 + 0f732f6 commit ff72e49

File tree

7 files changed

+134
-44
lines changed

7 files changed

+134
-44
lines changed

source/administration/sharding.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ use the following procedure as a quick starting point:
9696
sh.addShard( "<setName>/mongodb0.example.net:27027" )
9797

9898
Replace, ``<setName>`` with the name of the replica set, and
99-
MongoDB will discover all other members of the replica set. Repeat
100-
this step for each new shard in your cluster.
99+
MongoDB will discover all other members of the replica set.
100+
Repeat this step for each new shard in your cluster.
101101

102102
.. optional::
103103

@@ -222,6 +222,8 @@ procedure:
222222

223223
Replace ``<hostname>`` and ``<port>`` with the hostname and TCP
224224
port number of where the shard is accessible.
225+
Alternately specify a :term:`replica set` name and at least one
226+
hostname which is a member of the replica set.
225227

226228
For example:
227229

source/reference/command/addShard.txt

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,65 @@ addShard
66

77
.. dbcommand:: addShard
88

9-
:option name: Optional. Unless specified, a name will be
10-
automatically provided to uniquely identify
11-
the shard.
9+
:param string hostname: a hostname or replica-set/hostname string.
1210

13-
:option maxSize: Optional. Unless specified, shards will consume
14-
the total amount of available space on their
15-
machines if necessary. Use the ``maxSize`` value
16-
to limit the amount of space the database can
17-
use. Specify this value in megabytes.
11+
:param string name: Optional. Unless specified, a name will be
12+
automatically provided to uniquely identify
13+
the shard.
1814

19-
The :dbcommand:`addShard` command registers a new with a sharded
20-
cluster. You must run this command against a :program:`mongos`
21-
instance. The command takes the following form:
15+
:param integer maxSize: Optional. Unless specified, shards will consume
16+
the total amount of available space on their
17+
machines if necessary. Use the ``maxSize`` value
18+
to limit the amount of space the database can
19+
use. Specify this value in megabytes.
20+
21+
Use the :dbcommand:`addShard` command to add a database instance
22+
or replica set to a :term:`sharded cluster`.
23+
You must run this command against a :program:`mongos` instance.
24+
25+
The command takes the following form:
2226

2327
.. code-block:: javascript
2428

2529
{ addShard: "<hostname>:<port>" }
2630

31+
.. example::
32+
33+
.. code-block:: javascript
34+
35+
db.runCommand({addShard: "mongodb0.example.net:27027"})
36+
2737
Replace ``<hostname>:<port>`` with the hostname and port of the
28-
database instance you want to add as a shard. Because the
29-
:program:`mongos` instances do not have state and distribute
30-
configuration in the :term:`config database`, send this
31-
command to only one :program:`mongos` instance.
38+
database instance you want to add as a shard.
39+
40+
.. warning::
41+
42+
Do not use ``localhost`` for the hostname unless your
43+
:term:`configuration server <config database>`
44+
is also running on ``localhost``.
45+
46+
The optimal configuration is to deploy shards across
47+
:term:`replica sets <replica set>`.
48+
To add a shard on a replica set you must specify the name of the
49+
replica set and the hostname of at least one member of the replica
50+
set. You may specify all of the hostnames, but at least one member
51+
must be specified.
52+
53+
.. code-block:: javascript
54+
55+
{ addShard: "replica-set/hostname:port" }
56+
57+
.. example::
58+
59+
.. code-block:: javascript
60+
61+
db.runCommand({ addShard: "repl0/mongodb3.example.net:27327"})
62+
63+
If you specify additional hostnames, all must be members of the same
64+
replica set.
65+
66+
Send this command to only one :program:`mongos` instance, it will
67+
store shard configuration information in the :term:`config database`.
3268

3369
.. note::
3470

@@ -39,3 +75,10 @@ addShard
3975
The ``maxSize`` constraint prevents the :term:`balancer` from
4076
migrating chunks to the shard when the value of
4177
:status:`mem.mapped` exceeds the value of ``maxSize``.
78+
79+
.. seealso::
80+
81+
* :method:`sh.addShard()`
82+
* :doc:`/administration/sharding`
83+
* :doc:`/tutorial/add-shards-to-shard-cluster`
84+
* :doc:`/tutorial/remove-shards-from-cluster`

source/reference/method/db.printShardingStatus.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ db.printShardingStatus()
99
Provides a formatted report of the sharding configuration and the
1010
information regarding existing chunks in a :term:`sharded cluster`.
1111

12-
.. seealso:: :method:`sh.status()`
12+
This method must be executed on a :program:`mongos` instance.
13+
14+
This method is a wrapper around the :dbcommand:`printShardingStatus`
15+
command.
16+
17+
.. seealso:: :method:`sh.status()`, :dbcommand:`printShardingStatus`

source/reference/method/sh.addShard.txt

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,57 @@ sh.addShard()
66

77
.. method:: sh.addShard(host)
88

9-
:param host: Specify the hostname of a new shard server.
9+
:param string host: Specify the hostname of a database instance or a
10+
replica set configuration.
1011

11-
Use this to add shard instances to the current :term:`cluster`. The
12-
``host`` parameter can be in any of the following forms: ::
12+
Use this method to add a database instance or replica set to a
13+
:term:`sharded cluster`.
14+
This method must be run on a :program:`mongos` instance.
15+
The ``host`` parameter can be in any of the following forms: ::
1316

1417
[hostname]
1518
[hostname]:[port]
1619
[set]/[hostname]
1720
[set]/[hostname],[hostname]:port
1821

1922
You can specify shards using the hostname, or a hostname and port
20-
combination if the shard is running on a non-standard port. A
21-
:term:`replica set` can also function as a shard member. In these
22-
cases supply :method:`addShard <sh.addShard()>` with the set name,
23-
followed by at least one existing member of the set as a seed in a
24-
comma separated list, as in the final two examples.
25-
26-
This function provides a wrapper around the administrative command
27-
:dbcommand:`addShard`.
23+
combination if the shard is running on a non-standard port.
24+
25+
.. warning::
26+
27+
Do not use ``localhost`` for the hostname unless your
28+
:term:`configuration server <config database>`
29+
is also running on ``localhost``.
30+
31+
The optimal configuration is to deploy shards across
32+
:term:`replica sets <replica set>`.
33+
To add a shard on a replica set you must specify the name of the
34+
replica set and the hostname of at least one member of the replica
35+
set. You may specify all of the hostnames, but at least one member
36+
must be specified.
37+
38+
If you specify additional hostnames, all must be members of the same
39+
replica set.
40+
41+
.. code-block:: javascript
42+
43+
sh.addShard("set-name/seed-hostname")
44+
45+
.. example::
46+
47+
.. code-block:: javascript
48+
49+
sh.addShard("repl0/mongodb3.example.net:27327")
50+
51+
The :method:`sh.addShard()` method is a helper for the
52+
:dbcommand:`addShard` command.
53+
The :dbcommand:`addShard` command has additional options which are
54+
not available with this helper.
55+
56+
.. seealso::
57+
58+
* :dbcommand:`addShard`
59+
* :doc:`/administration/sharding`
60+
* :doc:`/tutorial/add-shards-to-shard-cluster`
61+
* :doc:`/tutorial/remove-shards-from-cluster`
62+

source/sharding.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ Sharding
77
Sharding distributes a
88
single logical database system across a cluster of machines. Sharding
99
uses range-based portioning to distribute :term:`documents <document>`
10-
based on a
11-
specific :term:`shard key`.
10+
based on a specific :term:`shard key`.
1211

1312
This page lists the documents, tutorials, and reference pages that
1413
describe sharding.
1514

1615
For an overview, see :doc:`/core/sharding`. To configure, maintain, and
17-
troubleshoot sharded clusters, see :doc:`/administration/sharding`. For
18-
deployment architectures, see
19-
:doc:`/administration/sharding-architectures`. For details on the
20-
internal operations of sharding, see :doc:`/core/sharding-internals`.
21-
For procedures for performing certain sharding tasks, see the :ref:`Tutorials <sharding-tutorials>`
22-
list.
16+
troubleshoot sharded clusters, see :doc:`/administration/sharding`.
17+
For deployment architectures, see :doc:`/administration/sharding-architectures`.
18+
For details on the internal operations of sharding, see :doc:`/core/sharding-internals`.
19+
For procedures for performing certain sharding tasks, see the
20+
:ref:`Tutorials <sharding-tutorials>` list.
2321

2422
Documentation
2523
-------------

source/tutorial/add-shards-to-shard-cluster.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Or you can use the :method:`sh.addShard()` helper in the
4848
Replace ``[hostname]`` and ``[port]`` with the hostname and TCP
4949
port number of where the shard is accessible.
5050

51+
.. warning::
52+
53+
Do not use ``localhost`` for the hostname unless your
54+
:term:`configuration server <config database>`
55+
is also running on ``localhost``.
56+
5157
For example:
5258

5359
.. code-block:: javascript

source/tutorial/deploy-shard-cluster.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The :program:`mongos` instance runs on the default MongoDB TCP port:
7474

7575
To start :program:`mongos` instance running on the
7676
``mongos0.example.net`` host, that connects to the config server
77-
instances running on the following hosts:
77+
instances running on the following hosts:
7878

7979
- ``mongoc0.example.net``
8080
- ``mongoc1.example.net``
@@ -112,18 +112,19 @@ port ``27017``, issue the following command:
112112

113113
mongo mongos0.example.net
114114

115-
Then, from the :program:`mongo` shell connected to the :program:`mongos`
115+
Then, from a :program:`mongo` shell connected to the :program:`mongos`
116116
instance, call the :method:`sh.addShard()` method for each shard that
117117
you want to add to the cluster:
118118

119119
.. code-block:: javascript
120120

121-
sh.addShard( "sfo30.example.net" )
122-
sh.addShard( "sfo40.example.net" )
121+
sh.addShard( "s0/sfo30.example.net" )
122+
sh.addShard( "s1/sfo40.example.net" )
123123

124-
If ``sfo30.example.net`` and ``sfo40.example.net`` are members of a
125-
replica set, MongoDB will discover all other members of the replica
126-
set.
124+
If the host you are adding is a member of a replica set, you
125+
*must* specify the name of the replica set. :program:`mongos`
126+
will discover the names of other members of the replica set based on
127+
the name and the hostname you provide.
127128

128129
These operations add two shards, provided by:
129130

0 commit comments

Comments
 (0)