Creating a second (clone) MongoDB ReplicaSet on same storage volumes

mongodbreplica-set

We are upgrading our software which is going to require an update to our MongoDB database. We plan on doing it by making a copy of the existing ReplicaSet with a new name and making our updates to the new one and then switching when everything is ready. Both of these ReplicaSet will be on the same servers.

I've already created the new standalone database under its new name (Did mongodumop from the Primary and then Restored it as a standalone under its new name on same volume as the Primary). What I want to do now is change this new database from a standalone to a ReplicaSet without impacting the original Production ReplicaSet

I found – Convert a Standalone to a Replica Set
http://docs.mongodb.org/manual/tutorial/convert-standalone-to-replica-set/

But this example just shows a single ReplicaSet and I just want to make sure that the procedure would still work with two databases on the same servers. The name of the ReplicaSet to be converted from a standalone is one of the mongo startup options ( –replSet ) in this example. Would that option need both the original and new ReplicaSrt names or just the new one to be converted from Standalone

Best Answer

To convert the standalone to a second replica set, without impacting the original replica set, you should follow directions for normal replica set setup, taking into account the following:

  1. Use a different replSet name for the new set
  2. Use a different dbpath for any new set members
  3. Use a different logpath for any new set members
  4. Setup the new members with different ports

If the above are accounted for then your 2 sets will be distinct and there will be no attempts between the 2 to communicate with each other. Please perform your rs.add() operations carefully as well, specifying the new member's ports rather than the old.