Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongo DB - All nodes secondary

Tags:

mongodb

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.

like image 803
Nick Avatar asked Mar 21 '12 22:03

Nick


People also ask

What are primary and secondary nodes in MongoDB?

Replication in MongoDB 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. The primary node receives all write operations.

What is replica set in MongoDB?

In simple terms, MongoDB replication is the process of creating a copy of the same data set in more than one MongoDB server. This can be achieved by using a Replica Set. A replica set is a group of MongoDB instances that maintain the same data set and pertain to any mongod process.

What is the maximum number of nodes in MongoDB replica set?

MongoDB supports replica sets, which can have up to 50 nodes.


1 Answers

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

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

like image 101
dicarsio Avatar answered Oct 03 '22 09:10

dicarsio