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 Answers
MongoDB doesn't do master-master replication; you can only have a single primary:
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.
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?
similar
would be apache couchdb