Im trying to install two nodes of mongo, each one locates in a different location with low latency. The architecture should be:

  • One node in DC, and the other node in DR. It is supposed to be only one node is the primary at a time (node in DC), if DC down, node in DR can be the master (can propose it manually as a primary).

  • When node in DR is manually changed to be primary, I can have time to bring up again node in DC, wait data to be synced to DC, then step down node in DR, change node in DC to be primary again.

I’m not sure the replica set can be applied to this. Please help me a solution for this.

Thank you.

1 Answer 1


MongoDB can elect a PRIMARY only if the majority is reachable. One node out of two is not the majority. Thus when one DB goes offline, the other cannot become the PRIMARY.

What you could do in such case, is to connect to the MonogDB which is available and modify the other member to {priority: 0, votes: 0}. Then the majority of "members which can be elected as PRIMARY" is 1 and it will be elected. Of course, this would not be an automatic failover.

Another option is to deploy an ARBITER. An MongoDB ARBITER is a very light process, it hardly consumes any processing power and does not store any data.

See also https://stackoverflow.com/questions/69658590/mongoclient-to-connect-to-multiple-hosts-to-handle-failover/69666511#69666511

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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