I currently have a MongoDB replica set configured as such:

    "_id" : "ahspy_mongo_set",
    "version" : 13,
    "members" : [
                    "_id" : 0,
                    "host" : "remotedatacenter.in.montreal.dns.com",
                    "priority" : 0
                    "_id" : 1,
                    "host" : "t1.micro.at.ec2.dns.com",
                    "arbiterOnly" : true
                    "_id" : 2,
                    "host" : "m1.xlarge.at.ec2.dns.com"

So basically, one server at EC2 that backups up to another server in Montreal which, for multiple reasons, cannot become master.

I want to change my structure and I'm not sure where to start without causing a lot of trouble. In fact, I'm not even sure what I want to do is possible.

What I want to do is take the main DB server I have at EC2 (m1.xlarge) and turn it into 3 m1.large shards. So basically, go from:

  • Replica at EC2 (m1.xlarge)
  • Backup Replica in Montreal
  • Arbiter


  • Replica at EC2
    • Shard 1 (m1.large)
    • Shard 2 (m1.large)
    • Shard 3 (m1.large)
  • Backup Replica in Montreal
  • Arbiter

Is this possible? Can I shard the replica set in EC2 while keeping only one server in the replica in Montreal? If so, what's the proper way to do this? I'm having a real "Chicken and Egg" issue with Replication/Sharding in Mongo so any help would be appreciated.

Thank you very much :).

1 Answer 1


Here's the basic steps:

  1. Start up mongos and config servers
  2. Make this replica set your first shard.
  3. Add shard 2
  4. Add shard 3

You can't use your backup replica as backup for all of your shards: it's just backup for that one replica set.

You should set up a separate replica set for each shard. If there's capacity for it on the Montreal server, you could put a backup member for shards 2 and 3 on that server, but they'd have to be separate mongod processes from the shard 1 member.

  • i'd take this advice since she works for 10gen
    – Mike
    Jul 15, 2011 at 19:36
  • Kristina: "You should set up a separate replica set for each shard." I've looked at the mongo sharding documentation 10ths of times and that's the part I'm not sure I understand correctly. What are you supposed to do first? Shard or Replicate? I'm having a hard time understanding the concept :\.
    – Pierre
    Jul 15, 2011 at 23:55
  • 1
    I did a blog post on this that might be helpful, it goes through setting them up together in more detail: snailinaturtleneck.com/blog/2010/08/30/…
    – kristina
    Jul 16, 2011 at 14:04
  • That was exactly the kind of documentation that my stupid brain needed. In fact, it looks like it was written for me :D. Thank you sooo much.
    – Pierre
    Jul 16, 2011 at 15:20
  • No problem, glad it helped :)
    – kristina
    Jul 16, 2011 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.