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.

  • 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})

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

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


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

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


    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.

    链接地址: http://www.djcxy.com/p/10578.html

    上一篇: Eclipse CDT:调试时'找不到源文件'

    下一篇: 所有节点次要