-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathsh.addShard.txt
116 lines (71 loc) · 2.74 KB
/
sh.addShard.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
=============
sh.addShard()
=============
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. method:: sh.addShard(<url>)
Adds a shard replica set to a :term:`sharded cluster`. This method
must be run on a :binary:`~bin.mongos` instance.
.. |dbcommand| replace:: :dbcommand:`addShard` command
.. include:: /includes/fact-mongosh-shell-method-alt.rst
The :method:`sh.addShard()` method has the following parameter:
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Parameter
- Type
- Description
* - ``host``
- string
- The replica set name, hostname, and port of at least one member of
the shard's replica set. Any additional replica set member hostnames
must be comma separated. For example:
.. code-block:: bash
<replica_set>/<hostname><:port>,<hostname><:port>, ...
The :method:`sh.addShard()` method has the following prototype form:
.. code-block:: javascript
sh.addShard("<replica_set>/<hostname><:port>")
.. warning::
Do not use ``localhost`` for the hostname unless your
config server
is also running on ``localhost``.
.. |mongodb-package| replace:: :binary:`~bin.mongos`
.. include:: /includes/note-deb-and-rpm-default-to-localhost.rst
.. include:: /includes/extracts/mongos-operations-wc-add-shard.rst
Compatibility
-------------
This method is available in deployments hosted in the following environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-atlas-support-no-free.rst
.. include:: /includes/fact-environments-onprem-only.rst
Considerations
--------------
Balancing
~~~~~~~~~
.. include:: /includes/fact-adding-shards-changes-cluster-balance.rst
Hidden Members
~~~~~~~~~~~~~~
.. |cmd-name| replace:: :method:`sh.addShard()`
.. include:: /includes/important-add-shard-not-compatible-with-hidden-members.rst
DDL Operations
~~~~~~~~~~~~~~
If you run ``sh.addShard`` while your cluster executes a DDL operation
(operation that modifies a collection such as
:dbcommand:`reshardCollection`), ``sh.addShard`` only executes after the
concurrent DDL operation finishes.
Example
-------
To add a shard, specify the name of the replica set and
the hostname of at least one member of the replica set, as a seed. If
you specify additional hostnames, all must be members of the same
replica set.
The following example adds a replica set named ``repl0`` and specifies
one member of the replica set:
.. code-block:: javascript
sh.addShard("repl0/mongodb3.example.net:27327")