@@ -4,18 +4,14 @@ Deploy a Replica Set
4
4
5
5
.. default-domain:: mongodb
6
6
7
- This tutorial describes how to create a three member
8
- :term:`replica set` from three existing instances of MongoDB .
9
- The tutorial provides one procedure for development and test systems and
10
- a separate procedure for production systems.
7
+ This tutorial describes how to create a three- member
8
+ :term:`replica set` from three existing :program:`mongod` instances .
9
+ The tutorial provides two procedures: one for development and test systems; and
10
+ a one for production systems.
11
11
12
- To deploy a replica set from a single standalone MongoDB instance, see
12
+ To instead deploy a replica set from a single standalone MongoDB instance, see
13
13
:doc:`/tutorial/convert-standalone-to-replica-set`.
14
14
15
- For background information on replica set deployments, see
16
- :doc:`/core/replication` and
17
- :doc:`/administration/replication-architectures`.
18
-
19
15
Overview
20
16
--------
21
17
@@ -29,31 +25,31 @@ Requirements
29
25
30
26
Most replica sets consist of two or more :program:`mongod`
31
27
instances. [#odd-numbered-set-sizes]_ This tutorial
32
- describes a three member set. Production environments should have at
28
+ describes a three member set. Production environments should have at
33
29
least three distinct systems so that each system can run its own
34
30
instance of :program:`mongod`. For development systems you can run all three instances
35
- of the :program:`mongod` process on a local system. (e.g. a laptop) or within a virtual
36
- instance. For production environments, you should endeavor to maintain as much separation
37
- between the members as possible. For example, when using virtual
31
+ of the :program:`mongod` process on a local system or within a virtual
32
+ instance. For production environments, you should maintain as much separation
33
+ between members as possible. For example, when using virtual
38
34
machines for production deployments, each member
39
- should live on separate host servers , served by redundant power circuits, and with
35
+ should live on a separate host server , served by redundant power circuits and with
40
36
redundant network paths.
41
37
42
38
.. [#odd-numbered-set-sizes] To ensure smooth :ref:`elections
43
39
<replica-set-elections>` always design replica sets with odd numbers
44
40
of members. Use :ref:`replica-set-arbiters` to ensure the set has
45
41
odd number of voting members and avoid tied elections.
46
42
47
- Procedure
48
- ---------
43
+ Procedures
44
+ ----------
49
45
50
46
These procedures assume you already have instances of MongoDB
51
47
installed on the systems you will add as members of your
52
48
:term:`replica set`. If you have not already installed MongoDB, see the
53
49
:ref:`installation tutorials <tutorials-installation>`.
54
50
55
- Deploy a Development or Testing Replica Set
56
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51
+ Deploy a Development or Test Replica Set
52
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57
53
58
54
The examples in this procedure create a new replica set named ``rs0``.
59
55
@@ -93,19 +89,12 @@ The examples in this procedure create a new replica set named ``rs0``.
93
89
:option:`--replSet <mongod --replSet>`.
94
90
95
91
#. Open a :program:`mongo` shell and connect to the first
96
- :program:`mongod` instance. If you're running this command remotely,
97
- replace "localhost" with the appropriate hostname. In a new shell
92
+ :program:`mongod` instance. In a new shell
98
93
session, enter the following:
99
94
100
95
.. code-block:: sh
101
96
102
- mongo localhost:27017
103
-
104
- .. note::
105
-
106
- In a replica set, *all* members of the set must use
107
- ``localhost`` addresses or *no* members of the replica set can
108
- use the ``localhost`` addresses.
97
+ mongo --port 27017
109
98
110
99
#. Use :method:`rs.initiate()` to initiate a replica set consisting of
111
100
the current member and using the default configuration:
@@ -120,21 +109,21 @@ The examples in this procedure create a new replica set named ``rs0``.
120
109
121
110
rs.conf()
122
111
123
- #. Add two members to the replica set by issuing a sequence of commands
124
- similar to the following.
112
+ #. Add the second and third :program:`mongod` instances to the replica
113
+ set using the :method:`rs.add()` method. For example, if your machine
114
+ name is ``mongodb.example.net``, you would issue the following.
125
115
126
116
.. code-block:: javascript
127
117
128
- rs.add("localhost :27018")
129
- rs.add("localhost :27019")
118
+ rs.add("mongodb.example.net :27018")
119
+ rs.add("mongodb.example.net :27019")
130
120
131
121
After these commands return you have a fully functional replica set.
132
122
New replica sets elect a :term:`primary` within a seconds.
133
123
134
124
#. Check the status of your replica set at any time with the
135
125
:method:`rs.status()` operation.
136
126
137
-
138
127
.. seealso:: The documentation of the following shell functions for
139
128
more information:
140
129
0 commit comments