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
to
- 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 :).
Here's the basic steps:
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.