1

Did anyone tried master-master replication in mongodb. i have used replica set and master-slave replication. But we want to go with 2 data centers and need a master in each data center. i am using latest 3.2 version. Can anyone tried this kind of architecture.

2
  • 2
    afaik there is no way to do master-master with mongodb even on the latest 3.2 versions Commented Jul 28, 2016 at 10:20
  • only master-master replication which is similar would be apache couchdb Commented May 3, 2021 at 19:07

2 Answers 2

1

MongoDB doesn't do master-master replication; you can only have a single primary:

Replication in MongoDB

A replica set is a group of mongod instances that maintain the same data set. 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.

0

If you want to have a "master" (primary) in each data center, the closest you can currently achieve, I believe, would be to increase the priority of one of the data-bearing nodes in each of the data centers so that they have a higher priority than the other members in the replica set. This way, when elections occur, the nodes with the highest priority would win the election as long as replication lag does not prevent it and/or you have an arbiter running to complete the trio to break any election ties if you only have 2 data-bearing nodes with one being in each of your data centers. But regardless, each node in the replica set can become a master (primary) as long as their oplog has not fallen too far behind because of replication lag across your wan or vpn or whatever your connection is between DCs. Does that help?

1
  • nope actually.i need 3 nodes in each data center.
    – kasi
    Commented Jul 29, 2016 at 6:01

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.