Nick
Nick

Reputation: 3156

mongo DB - All nodes secondary

All of the nodes in our cluster are "secondary" and no node is stepping up as "primary".

How do I force a node to become primary?

===SOLUTION=== We had 4 nodes in our replica set, when we are supposed to only have an odd number of nodes.

  1. Remove a node so you have an odd number of nodes

    • rs.config()

    Edit the list of servers in notepad/textpad removing one of the servers

    • config = POST_MODIFIED_LIST_HERE

    • rs.reconfig(config, {force:true})

  2. Stop the mongodb service 'mongod' on all nodes, and bring them back up

  3. Done

If this doesn't fix it, try adding a priority to one of the nodes.

Upvotes: 9

Views: 8414

Answers (2)

Elomis
Elomis

Reputation: 532

If you have an even number of nodes, one answer is to remove one. Another answer can be to add an arbiter, which doesn't have a copy of the data but participates in the cluster purely for voting and breaks ties. This way you get odd vote numbers and guaranteed elections, but the availability/capacity of four nodes.

Upvotes: 2

dicarsio
dicarsio

Reputation: 472

You can use the following instructions available at MongoDB's website:

http://www.mongodb.org/display/DOCS/Forcing+a+Member+to+be+Primary

Upvotes: 3

Related Questions