Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set up Mongo Cluster across 2 data centers with writing enabled on both

We're planning to expand our software to the South East Asia region. Our self-hosted Mongo Cluster is fully set up at China's AWS Data Center. How can we set up the MongoDB replicate set to AWS Singapore and allow writing on both regions and rely on MongoDB for asynchronously sync up data behind the scenes?

like image 345
angelokh Avatar asked Oct 14 '22 19:10

angelokh


1 Answers

What you are trying to do is not possible with MongoDB replica set. If you checkout the documentation here:

A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes

If you really want to be able to do write operations on more than one server, you will need to shard your collections. You can go through the documentation here to get started.

like image 119
Ashish Avatar answered Oct 20 '22 17:10

Ashish