Search code examples
mongodbreplicationdistributeddatabase-replicationmaster-slave

How to assign new master database in a geo distributed MongoDB cluster?


I need to have MongoDB databases in different data centers. One MongoDB database will be a master in a main data center and other will be slaves in other data centers. How can we assign a new master database in different data centers if our master database in the main data center will die?


Solution

  • Assuming you mean a distributed replica set between data centres, the other nodes will elect a new master if the master should fail.

    If you have a preference for what node should become the new master, then it is possible to configure a preference for this case.

    I suggest you read up the section on Replica set elections in the MongoDB Docs for more information.