MongoDB ReplicaSet - PRIMARY role falls to SECONDARY when only PRIMARY is left

后端 未结 4 1417
梦谈多话
梦谈多话 2021-01-03 07:33

I am investigating using MongoDB ReplicaSet for high availability.

But just discovered that in ReplicaSet with 3 nodes, if PRIMARY mongod is the only one left (that

4条回答
  •  感情败类
    2021-01-03 08:33

    Just to chime in on the answers. The behavior in this scenario is expected. MongoDB uses a leader election algorithm to elect the new leader. So if there is no majority you cannot elect a leader and hence no writes.

    Your only option at the point where 2 nodes are down is to reconfigure your replica set as a 1 node replica set to make it writeable. You can do this using the rs.reconfig cmd with just one server. However please note that this should just be a temporary and emergency configuration. For the longer duration you should have an odd number of total nodes (3+) in your replica set configuration.

提交回复
热议问题