@@ -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`
0 commit comments