[SERVER-3452] From single node to replica set without restart... possible? Created: 20/Jul/11  Updated: 29/Aug/11  Resolved: 20/Jul/11

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 1.6.1
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Brian Konash Assignee: Unassigned
Resolution: Done Votes: 0
Labels: replication
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux version 2.6.18-164.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Thu Sep 3 03:28:30 EDT 2009


Participants:

 Description   

I have a single node running MongoDB 1.6.1 in production, and I'd like to create and then add it to a replica set. I'm wondering what the best way to do this is, and if I can do it without any downtime on the original production node. The approach I'd like to take is:

1. Create an arbiter node and add it to the replica set.
2. Create a secondary node and add it to the replica set.
3. Add the original production node to the replica set.
4. Initiate the replica set on the original production node.

The problem I'm running into is that I don't seem to be able to figure out how to add the original production node to the replica set without restarting it and adding the --replSet option on startup. Is there any way to do this without any downtime on the original production node?



 Comments   
Comment by Brian Konash [ 20/Jul/11 ]

Here's my revised plan with mongodb1 and mongodb2 as database nodes and mongodb3 as the arbiter (all running on port 27017):

1. Restart MongoDB on mongodb1, adding "--replSet my-rs" parameter to add it to a new replica set.
2. Run rs.initiate(); on mongodb1 to initiate the data into the replica set, making mongodb1 the master node.
3. Run rs.status(); on mongodb1 until it shows that the initiation is complete.
4. Start MongoDB on mongodb2 with "--replSet my-rs" parameter to add it to the replica set.
5. Run rs.add({_id:1, host:"mongodb2:27017"}); on mongodb1 so that it is aware of the new node.
6. Run rs.status(); on mongodb1 until it shows that mongodb2 has the replicated data and is operational.
7. Start MongoDB on mongodb3, adding "--replSet my-rs --oplogSize 8" parameters to add the arbiter to the replica set.
8. Run rs.add({_id:2, host:"mongodb3:27017", arbiterOnly:true}) on mongodb1 so that it is aware of the arbiter.
9. Run rs.status(); on mongodb1 until it shows that the the arbiter is up.
10. Go to the bar!

Does anything stand out as being incorrect about this?

Comment by Brian Konash [ 20/Jul/11 ]

Awesome. Thanks!

Comment by Scott Hernandez (Inactive) [ 20/Jul/11 ]

You must restart the single server to add --replSet and build the oplog (which could take a while depending on how large you make it, and who FS you have).

You should restart the primary (existing) node first to create the replicaset, then add the arbiter and secondary.

Generated at Thu Feb 08 03:03:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.