Replica set with 2 data centers

How can I deploy a replica set between 2 data centers so that both can be writable if the other fails?

Hi @Martin_Terreni ,

Replica set concepts allow only a single Primary to be available at a specific point in time. However, in case of a datacenter failure we have topologies to allow automatic DC failovers:

If you need both datacenters to be actively writing you can look into the following sharding concept:


Thanks for the answer.
We only need one writable DC at a time. It is just for fail over.

So it seems there is no solution but to create an automatic script to add arbiters.

@Martin_Terreni ,

Or to use a third location for that “arbiter” with 5 member replica set…

This could be a simple moderator to allow majority if any of the 2 DC’s fails. But you are correct you need 3 different locations to allow automatic failover with a Primary in 2 DC’s