@@ -58,28 +58,56 @@ availability requirements, you may:
5858Procedures
5959----------
6060
61- .. _replica-set-change-hostname-no-downtime:
62-
63- Changing Hostnames while Maintaining the Replica Set's Availability
64- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61+ .. _givens:
6562
66- Given a :term:`replica set` with three members
63+ Given a :term:`replica set` with three members:
6764
6865- ``database0.example.net:27017`` (the :term:`primary`)
6966
7067- ``database1.example.net:27018``
7168
7269- ``database2.example.net:27019``
7370
74- This procedure changes the hostnames to the following, while maintaining
75- the set's availability:
71+ And with the following :func:`rs.config()` output:
72+
73+ .. code-block:: javascript
74+
75+ {
76+ "_id" : "rs",
77+ "version" : 3,
78+ "members" : [
79+ {
80+ "_id" : 0,
81+ "host" : "database0.example.net:27017"
82+ },
83+ {
84+ "_id" : 1,
85+ "host" : "database1.example.net:27018"
86+ },
87+ {
88+ "_id" : 2,
89+ "host" : "database2.example.net:27019"
90+ }
91+ ]
92+ }
93+
94+ The following procedures change the members' hostnames as follows:
7695
7796- ``mongodb0.example.net:27017`` (the primary)
7897
7998- ``mongodb1.example.net:27018``
8099
81100- ``mongodb2.example.net:27019``
82101
102+ Use the procedure appropriate to your situation.
103+
104+ .. _replica-set-change-hostname-no-downtime:
105+
106+ Changing Hostnames while Maintaining the Replica Set's Availability
107+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108+
109+ This procedure uses the above ":ref:`givens <givens>`".
110+
83111#. For each :term:`secondary` in the replica set, perform the
84112 following sequence of operations:
85113
@@ -148,81 +176,50 @@ the set's availability:
148176
149177#. Open a :program:`mongo` shell connected to the primary.
150178
151- #. To confirm the new configuration, call :func:`rs.status ()` in the
179+ #. To confirm the new configuration, call :func:`rs.config ()` in the
152180 :program:`mongo` shell.
153181
154- Your output should look similar to this :
182+ Your output should resemble :
155183
156184 .. code-block:: javascript
157185
158186 {
159- "set" : "rs",
160- "date" : ISODate("2012-08-17T20:55:59Z"),
161- "myState" : 1,
162- "members" : [
163- {
164- "_id" : 0,
165- "name" : "mongodb0.example.net:27017",
166- "health" : 1,
167- "state" : 1,
168- "stateStr" : "PRIMARY",
169- "optime" : {
170- "t" : 1345235703000,
171- "i" : 1
172- },
173- "optimeDate" : ISODate("2012-08-17T20:35:03Z"),
174- "self" : true
175- },
176- {
177- "_id" : 1,
178- "name" : "mongodb1.example.net:27018",
179- "health" : 1,
180- "state" : 2,
181- "stateStr" : "SECONDARY",
182- "uptime" : 1260,
183- "optime" : {
184- "t" : 1345235703000,
185- "i" : 1
186- },
187- "optimeDate" : ISODate("2012-08-17T20:35:03Z"),
188- "lastHeartbeat" : ISODate("2012-08-17T20:55:58Z"),
189- "pingMs" : 0
190- },
191- {
192- "_id" : 2,
193- "name" : "mongodb2.example.net:27019",
194- "health" : 1,
195- "state" : 2,
196- "stateStr" : "SECONDARY",
197- "uptime" : 1256,
198- "optime" : {
199- "t" : 1345235703000,
200- "i" : 1
201- },
202- "optimeDate" : ISODate("2012-08-17T20:35:03Z"),
203- "lastHeartbeat" : ISODate("2012-08-17T20:55:58Z"),
204- "pingMs" : 0
205- }
206- ],
207- "ok" : 1
208- }
187+ "_id" : "rs",
188+ "version" : 4,
189+ "members" : [
190+ {
191+ "_id" : 0,
192+ "host" : "mongodb0.example.net:27017"
193+ },
194+ {
195+ "_id" : 1,
196+ "host" : "mongodb1.example.net:27018"
197+ },
198+ {
199+ "_id" : 2,
200+ "host" : "mongodb2.example.net:27019"
201+ }
202+ ]
203+ }
209204
210205.. _replica-set-change-hostname-downtime:
211206
212207Changing All Hostnames in Replica Set at Once
213208~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214209
210+ This procedure uses the above ":ref:`givens <givens>`".
211+
215212#. Stop all members in the :term:`replica set`.
216213
217214#. Restart each member *on a different port* and *without* using the
218215 :option:`--replSet <mongod --replset>` run-time option. Changing
219216 the port number during maintenance prevents clients from connecting
220- to this host while you perform maintenance. Use a command that
221- resembles the following:
217+ to this host while you perform maintenance. Use the member's usual :option:`--dbpath`, which in this
218+ example is ``/data/db1``. Use a command that resembles the following:
222219
223220 .. code-block:: sh
224221
225- mongod --dbpath /data/db / --port 37017
222+ mongod --dbpath /data/db1 / --port 37017
226223
227224#. For each member of the replica set, perform the following sequence
228225 of operations:
@@ -249,11 +246,11 @@ Changing All Hostnames in Replica Set at Once
249246
250247 cfg = db.system.replset.findOne( { "_id": "rs" } )
251248
252- cfg.members[0].host = "mdb0 .example.net:27017"
249+ cfg.members[0].host = "mongodb0 .example.net:27017"
253250
254- cfg.members[1].host = "mdb1 .example.net:27018"
251+ cfg.members[1].host = "mongodb1 .example.net:27018"
255252
256- cfg.members[2].host = "mdb2 .example.net:27019"
253+ cfg.members[2].host = "mongodb2 .example.net:27019"
257254
258255 db.system.replset.update( { "_id": "rs" } , cfg )
259256
@@ -266,7 +263,7 @@ Changing All Hostnames in Replica Set at Once
266263
267264 .. code-block:: sh
268265
269- mongod --dbpath /data/db / --port 27017 --replSet rs
266+ mongod --dbpath /data/db1 / --port 27017 --replSet rs
270267
271268#. Connect to one of the :program:`mongod` instances
272269 using the :program:`mongo` shell. For example:
@@ -275,62 +272,28 @@ Changing All Hostnames in Replica Set at Once
275272
276273 mongo --port 27017
277274
278- #. To confirm that the set has reconfigured , call :func:`rs.status ()` in the
275+ #. To confirm the new configuration , call :func:`rs.config ()` in the
279276 :program:`mongo` shell.
280277
281- Your output should look similar to this :
278+ Your output should resemble :
282279
283280 .. code-block:: javascript
284281
285282 {
286- "set" : "rs",
287- "date" : ISODate("2012-08-17T20:55:59Z"),
288- "myState" : 1,
289- "members" : [
290- {
291- "_id" : 0,
292- "name" : "mdb0.example.net:27017",
293- "health" : 1,
294- "state" : 1,
295- "stateStr" : "PRIMARY",
296- "optime" : {
297- "t" : 1345235703000,
298- "i" : 1
299- },
300- "optimeDate" : ISODate("2012-08-17T20:35:03Z"),
301- "self" : true
302- },
303- {
304- "_id" : 1,
305- "name" : "mdb1.example.net:27018",
306- "health" : 1,
307- "state" : 2,
308- "stateStr" : "SECONDARY",
309- "uptime" : 1260,
310- "optime" : {
311- "t" : 1345235703000,
312- "i" : 1
313- },
314- "optimeDate" : ISODate("2012-08-17T20:35:03Z"),
315- "lastHeartbeat" : ISODate("2012-08-17T20:55:58Z"),
316- "pingMs" : 0
317- },
318- {
319- "_id" : 2,
320- "name" : "mdb2.example.net:27019",
321- "health" : 1,
322- "state" : 2,
323- "stateStr" : "SECONDARY",
324- "uptime" : 1256,
325- "optime" : {
326- "t" : 1345235703000,
327- "i" : 1
328- },
329- "optimeDate" : ISODate("2012-08-17T20:35:03Z"),
330- "lastHeartbeat" : ISODate("2012-08-17T20:55:58Z"),
331- "pingMs" : 0
332- }
333- ],
334- "ok" : 1
335- }
336-
283+ "_id" : "rs",
284+ "version" : 4,
285+ "members" : [
286+ {
287+ "_id" : 0,
288+ "host" : "mongodb0.example.net:27017"
289+ },
290+ {
291+ "_id" : 1,
292+ "host" : "mongodb1.example.net:27018"
293+ },
294+ {
295+ "_id" : 2,
296+ "host" : "mongodb2.example.net:27019"
297+ }
298+ ]
299+ }
0 commit comments