MongoDB Sharding and Replication

389 Views Asked by At

I've already setup MongoDB sharding and now I need to setup replication for availability. How do I do this? I've currently got this:

  • 2 mongos instances running in different datacenters
  • 2 mongod config servers running in different datacenters
  • 2 mongod shard servers running in different datacenters
  • all communication is over a private network setup by my provider that is available cross-datacenter

Do I just setup replication on each server (by assigning each a secondary)?

3

There are 3 best solutions below

0
On BEST ANSWER

I would build the whole system in 3 DCs', for redundancy. Every data center would have three servers with services of:

  1. 1x mongoS at Server1
  2. 1x node of config server replica set at Server1
  3. 1x node of shard1 replica set at Server2
  4. 1x node of shard2 replica set at Server3

So, a total of 9 nodes (physical or virtual).

If we "lose" one DC, everything works still, because we have a majority in all three replica sets.

0
On

You need 3 servers in each replica set for redundancy. Either put the third one in one of the data centers or get a third data center.

  • The config replica set needs 3 servers.
  • Each of the shard replica sets needs 3 servers.
  • You can keep the 2 mongoses.
0
On

After reading through the suggestions from D. SM and JJussi (thanks by the way), I'll be implementing the following infrastructure:

  • 3 monogs instances spaced across different datacenters
  • 3 config servers spaced across different datacenters
  • 2 shards with 2 storage servers spaced across different datacenters with an arbiter each (to cut down on costs for now) each

Thanks once again for your input.