Skip to content

Commit 415a101

Browse files
author
Bob Grabar
committed
DOCS-324 consolidated procedure for add members
1 parent 3315b08 commit 415a101

File tree

2 files changed

+102
-77
lines changed

2 files changed

+102
-77
lines changed

source/administration/replica-sets.txt

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ Before adding a new member to an existing :term:`replica set`, do one of
341341
the following to prepare the new member's :term:`data directory <dbpath>`:
342342

343343
- Make sure the new member's data directory *does not* contain data. The
344-
new member will copy the data directory from an existing member.
344+
new member will copy the data from an existing member.
345345

346-
If the new member is in a :term:`recovering` state, it must exit
346+
If the new member is in a :term:`recovering` state, it must exit and
347347
become a :term:`secondary` before MongoDB
348348
can copy all data as part of the replication process. This process
349349
takes time but does not require administrator intervention.
@@ -364,39 +364,8 @@ the following to prepare the new member's :term:`data directory <dbpath>`:
364364
Use :method:`db.printReplicationInfo()` to check the current state of
365365
replica set members with regards to the oplog.
366366

367-
To add a member to an existing replica set, deploy a new
368-
:program:`mongod` instance, specifying the name of the replica set
369-
(i.e. :data:`setname <rs.conf._id>`) on the command line with the
370-
:option:`--replSet <mongod --replSet>` option or in the configuration
371-
file with the :setting:`replSet`. Take note of the host name and port
372-
information for the new :program:`mongod` instance.
373-
374-
Then log in to the current :term:`primary` using the :program:`mongo`
375-
shell. Issue the :method:`db.isMaster()` command when connected to *any*
376-
member of the set to determine the current primary. Issue the
377-
following command to add the new member to the set:
378-
379-
.. code-block:: javascript
380-
381-
rs.add("mongo2.example.net:27017")
382-
383-
Alternately, specify an entire configuration document with some or all
384-
of the fields in a :data:`members <rs.conf.members>` document. For
385-
example:
386-
387-
.. code-block:: javascript
388-
389-
rs.add({_id: 1, host: "mongo2.example.net:27017", priority: 0, hidden: true})
390-
391-
This configures a :term:`hidden member` that is accessible at
392-
``mongo2.example.net:27017``. See :data:`host <members[n].host>`,
393-
:data:`priority <members[n].priority>`, and :data:`hidden
394-
<members[n].hidden>` for more information about these settings. When
395-
you specify a full configuration object with :method:`rs.add()`, you must
396-
declare the ``_id`` field, which is not automatically populated in
397-
this case.
398-
399-
.. seealso:: :doc:`/tutorial/expand-replica-set`.
367+
For the procedure to add a member to a replica set, see
368+
:doc:`/tutorial/expand-replica-set`.
400369

401370
.. _replica-set-admin-procedure-remove-members:
402371

@@ -446,7 +415,6 @@ Use :method:`rs.reconfig()` to change the value of the
446415
number. :method:`rs.reconfig()` will not change the value of
447416
:data:`members[n]._id`.
448417

449-
450418
.. code-block:: javascript
451419

452420
cfg = rs.conf()

source/tutorial/expand-replica-set.txt

Lines changed: 98 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,43 @@ Add Members to a Replica Set
77
Overview
88
--------
99

10-
This is a tutorial explaining how to add an additional node to an
10+
This tutorial explains how to add an additional member to an
1111
existing replica set.
1212

13-
Before adding new members, note the
14-
:doc:`/administration/replication-architectures` documentation for
15-
more background on replication deployment patterns.
13+
Before adding a new member, see the :ref:`replica-set-admin-procedure-add-member`
14+
topic in the :doc:`/administration/replica-sets` document.
15+
16+
For background on replication deployment patterns, see the
17+
:doc:`/administration/replication-architectures` document.
1618

1719
Requirements
1820
------------
1921

2022
#. An active replica set.
2123

2224
#. A new MongoDB system capable of supporting your dataset, accessible by
23-
the active replica set through the network.
25+
the active replica set through the network.
2426

2527
If neither of these conditions are satisfied, please use the MongoDB
2628
:ref:`installation tutorial <tutorials-installation>` and the
27-
":doc:`/tutorial/deploy-replica-set`" guide instead.
29+
:doc:`/tutorial/deploy-replica-set` guide instead.
30+
31+
Procedures
32+
----------
2833

29-
Procedure
30-
---------
34+
.. _procedure-assumption-add-member-rs:
3135

32-
For the following procedure, examples are provided using the following
36+
The examples in this procedure use the following
3337
configuration:
3438

35-
- The active replica set: ``rs0``
39+
- The active replica set is ``rs0``.
3640

37-
- The new MongoDB replica set to be added: ``mongodb3.example.net``.
41+
- The new member to be added is ``mongodb3.example.net``.
3842

39-
- :program:`mongod` instance running on default port: ``27017``.
43+
- The :program:`mongod` instance default port is ``27017``.
4044

41-
- The ``mongodb.conf`` on the new replica set system resembling the following:
45+
- The ``mongodb.conf`` configuration file exists in the ``/etc``
46+
directory and contains the following replica set information:
4247

4348
.. code-block:: cfg
4449

@@ -54,53 +59,105 @@ configuration:
5459

5560
replSet = rs0
5661

57-
For more documentation of the configuration options used above refer to:
58-
:setting:`dbpath`, :setting:`port`, :setting:`replSet`,
59-
:setting:`bind_ip`, and :setting:`fork`. Consider any additional
60-
:doc:`configuration options </reference/configuration-options>` that
61-
your deployment may require.
62+
For more information on configuration options, see
63+
:doc:`/reference/configuration-options`.
6264

63-
#. On the primary node, Start the :program:`mongod` process with the
64-
following command:
65+
.. _replica-set-add-member:
6566

66-
.. code-block:: sh
67+
Add a Member to an Existing Replica Set
68+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6769

68-
mongod --config /etc/mongodb.conf
70+
This procedure uses the above :ref:`example configuration <procedure-assumption-add-member-rs>`.
6971

70-
.. note::
72+
1. Deploy a new :program:`mongod` instance, specifying the name of the
73+
replica set. You can do this one of two ways:
7174

72-
The primary node is the only node which can add or remove
73-
members to the replica set. If you do not know the primary
74-
node, log into any of the existing members of the current
75-
replica set by issuing the following command:
75+
- Using the ``mongodb.conf`` file. On the :term:`primary`, issue a
76+
command that resembles the following:
7677

77-
.. code-block:: sh
78+
.. code-block:: sh
7879

79-
mongo mongodb0.example.net
80-
81-
If this instance is not currently the :term:`primary` node, use
82-
the :method:`db.isMaster()` function to determine which node is in
83-
the :data:`isMaster.primary` field. Issue the following command.
80+
mongod --config /etc/mongodb.conf
81+
82+
- Using command line arguments. On the :term:`primary`, issue command
83+
that resembles the following:
84+
85+
.. code-block:: sh
86+
87+
mongod --replSet rs0
88+
89+
Take note of the host name and port information for the new
90+
:program:`mongod` instance.
91+
92+
#. Open a :program:`mongo` shell connected to the replica set's primary:
93+
94+
.. code-block:: sh
95+
96+
mongo
97+
98+
.. note::
99+
100+
The primary is the only member that can add or remove members from
101+
the replica set. If you do not know which member is the primary,
102+
log into any member of the replica set using :program:`mongo` and
103+
issue the :method:`db.isMaster()` command to determine which
104+
member is in the :data:`isMaster.primary` field. For example:
84105

85106
.. code-block:: javascript
86107

108+
mongo mongodb0.example.net
109+
87110
db.isMaster()
88111

89-
Now disconnect from the current client and reconnect to the
90-
primary node.
112+
If you are not connected to the primary, disconnect from the
113+
current client and reconnect to the primary.
91114

92-
#. Now issue the following command to add the new member to the
115+
#. In the :program:`mongo` shell, issue the following command to add the new member to the
93116
replica set.
94117

95118
.. code-block:: javascript
96119

97120
rs.add("mongodb3.example.net")
98121

99-
Congratulations! You have successfully expanded an existing replica
100-
set. You can use the :method:`rs.status()` function to provide an
101-
overview of :doc:`replica set status </reference/replica-status>`, or
102-
the :method:`rs.conf()` for the complete :doc:`replica set
103-
configuration </reference/replica-configuration>`.
122+
.. note::
123+
124+
You can also include the port number, depending on your setup:
125+
126+
.. code-block:: javascript
127+
128+
rs.add("mongodb3.example.net:27017")
129+
130+
#. Verify that the member is now part of the replica set by
131+
calling the :method:`rs.config()` method,
132+
which displays the :doc:`replica set configuration </reference/replica-configuration>`:
133+
134+
.. code-block:: javascript
135+
136+
rs.config()
137+
138+
You can use the :method:`rs.status()` function to provide an
139+
overview of :doc:`replica set status </reference/replica-status>`.
140+
141+
.. _replica-set-add-member-alternate-procedure:
142+
143+
Add a Member to an Existing Replica Set (Alternate Procedure)
144+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145+
146+
Alternately, you can add a member to a replica set by specifying an
147+
entire configuration document with some or all of the fields in a
148+
:data:`members <rs.conf.members>` document. For example:
149+
150+
.. code-block:: javascript
151+
152+
rs.add({_id: 1, host: "mongodb3.example.net:27017", priority: 0, hidden: true})
153+
154+
This configures a :term:`hidden member` that is accessible at
155+
``mongodb3.example.net:27017``. See :data:`host <members[n].host>`,
156+
:data:`priority <members[n].priority>`, and :data:`hidden
157+
<members[n].hidden>` for more information about these settings. When you
158+
specify a full configuration object with :method:`rs.add()`, you must
159+
declare the ``_id`` field, which is not automatically populated in this
160+
case.
104161

105162
Production Notes
106163
----------------

0 commit comments

Comments
 (0)