Make Priority 0 Members PRIMARY?

25 views
Skip to first unread message

Carlos

unread,
Dec 6, 2016, 8:35:36 AM12/6/16
to mongodb-user
My replset is as follows:

1. PRIMARY = mongo1
2. SECONDARY = mongo2
3. SECONDARY = mongo3
4. SECONDARY / Priority 0 = mongo4
5. SECONDARY / Priority 0 = mongo5

My question is now that I have successfully added mongo4/5 to the replset as priority 0 members, how to I force mongo4 or mongo5 to become PRIMARY?

1-3 = NYC, NY
4-5 = Atlanta, GA. 

If the NY data center does go down, how could I force my priority 0 members to be elected as PRIMARY? I can assume I would need to 1st change the priority of the mongo4,5 nodes from 0 and then force an election but how can I force a specific instance to be isMaster()?

Thanks for any info!

Žygimantas Stauga

unread,
Dec 6, 2016, 9:57:23 AM12/6/16
to mongodb-user
1-3 / Change priority to: 10
4-5 / Change priority to: 1

Alex Penazzi

unread,
Dec 6, 2016, 10:14:52 AM12/6/16
to mongodb-user
Hi Carlos,
you have different way to do this, but keep in mind that the highest is the priority, the highest is the possibility that the node become primary.
I do not know which mongodb version you are using, but according with this:
you should setup priority highest number to the node it should become primary

best
alex

Aly Cabral

unread,
Dec 20, 2016, 3:46:24 PM12/20/16
to mongodb-user

Hi Carlos,

As the other answers address, the priority value of 0 suggests that you never want that node to become primary in any case. However in your use case, you would want to make sure you have a majority when electing a new primary. In your current topology, with only two nodes in the second data center, a majority cannot be achieved if the NY data center goes down. See also Replica Set: fault tolerance. You could do something like this however:

Priority 10: mongod1, mongod2, mongod3 - NYC, NY

Priority 1: mongod4, mongod5, mongod6 - Atlanta, GA
arbiter - hosted on AWS (or the cloud flavor of your choosing somewhere else not in Atlanta or NY). 

An arbiter does not hold any data, but is allowed a vote in an election for primary. The arbiters default priority is 1 but it can never be elected primary. But an arbiter does allow you to get a majority if either of your datacenters in NY or GA goes down. Another optional topology is adding two additional host arbiters to your current setup:

Priority 10: mongod1, mongod2, mongod3 - NYC, NY
Priority 1: mongod4, mongod5 - Atlanta, GA
arbiter1, arbiter2 - hosted on AWS (or the cloud flavor of your choosing somewhere else not in Atlanta or NYC).

Hope that helps. Let me know if you have any other questions!

Aly

Reply all
Reply to author
Forward
0 new messages