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

106 views
Skip to first unread message

Paul H

unread,
Nov 14, 2014, 2:00:43 PM11/14/14
to mongod...@googlegroups.com

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.

So our current production database is a ReplicaSet across 3 servers and is on Mongo-a, Mongo-b and Mongo-c We want to have our new (soon to be production) database spread over these same three servers

I've already created the new standalone database under its new name (Did mongodump 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. In the example the name of the ReplicaSet to be converted from a standalone is one of the mongo startup options ( --replSet ) . Would that option need both the original and new ReplicaSrt names or just the new one to be converted from Standalone ?

The version of MingoDB we are running is 2.6.5 and this is being done on Ubuntu 12.04


Andrés Torres

unread,
Nov 14, 2014, 5:48:53 PM11/14/14
to mongod...@googlegroups.com
Hi Paul, 

Here is my suggestion on how to proceed:

First, the new replicaSet and the existing replicaSet could run in the same servers. The thing is you should run different mongod instances with different ports on the same servers.

Imagine the actual configuration is:

Mongo-a: is running a mongod instance in default port 27017 with existing ReplicaSet

Mongo-b: is running a mongod instance in default port 27017 with existing ReplicaSet

Mongo-c: is running a mongod instance in default port 27017 with existing ReplicaSet

The new configuration will be:

Mongo-a: 
       A mongod instance running in default port 27017 with existing ReplicaSet
       A mongod instance running in  port 30999 with new ReplicaSet
Mongo-b:
       A mongod instance running in default port 27017 with existing ReplicaSet
       A mongod instance running in  port 30999 with new ReplicaSet
Mongo-c:
       A mongod instance running in default port 27017 with existing ReplicaSet
       A mongod instance running in  port 30999 with new ReplicaSet

Please remember that the new replicaSet instances need to have a different dbpath and make sure that you have enough free space on those servers to run two instances at the same time.

The way to launch the new mongod instances will be:

mongod --dbpath /new/replicaSet/path --port 30999 --replSet newRS

Then you can configure the new replicaSet initiating it and adding the others members. Finally you could use mongorestore to restore the data.

If you still want to convert the current standalone, you just have to start the first mongod instance of the new replicaSet with the dbpath pointing to the standalone dbpath.

I hope to be clear enough. 

Asya Kamsky

unread,
Nov 16, 2014, 6:08:44 PM11/16/14
to mongod...@googlegroups.com
Hi Paul,

Key thing to keep in mind is that when you dumped via mongodump and restored into standalone, no replica set information came along, because mongodump does not dump the local db.   So no worries, your standalone doesn't know about the old replica set and you can safely convert it to a new replica set.

Asya
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/d4bfd120-1f20-4965-8d74-7ad020a0d637%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul H

unread,
Nov 18, 2014, 1:26:34 PM11/18/14
to mongod...@googlegroups.com
Hi Andrés,

Thanks for your response. First I want to confirm something that seems to be implied from your response and others I have talked to. Can I have a single instance of Mongo accessing multiple(in my case two) ReplicaSets or does each ReplicaSet require its own mongod instance? My original thought was to have both running under the same Mongod instance and be differentiated by their name. Since the internal structure was different and was being accessed by two different versions of the app, I thought having the two different names would be enough

From the mongorestore I did creating what should be a standalone version, it has the same dbpath but different file names and seems to coexisting nicely as far as I can tell from RoboMongo (it shows up and I can display its content.)

Assuming that I can have both ReplicaSets under a single mongos instance would I start it with both ReplicaSet names in the mongod startup option ( --replSet <setname> ) or would I only add the new one and the original would be brought in because it was already known?

I assume then I would go forward with the normal steps in http://docs.mongodb.org/manual/tutorial/convert-standalone-to-replica-set/

Thanks,
Paul

Asya Kamsky

unread,
Nov 19, 2014, 4:45:15 AM11/19/14
to mongodb-user

Paul,

It's *not* possible to have a single mongod process access more than one data directory nor be a member of more than one replica set.

To put it another way, a *mongod* can ONLY be a member of ONE replica set.

Asya

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

Paul Hardwick

unread,
Nov 19, 2014, 11:31:54 AM11/19/14
to mongod...@googlegroups.com
Thanks for the confirmation Asya
I never found it explicitly stated but that was what I was coming to based on the implied  references I was seeing

You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/opQuX2qbzio/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.

To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
Reply all
Reply to author
Forward
0 new messages