为什么mongodb副本集需要一个奇数个投票节点? [英] Why does a mongodb replica set require an odd number of voting nodes?

查看:338
本文介绍了为什么mongodb副本集需要一个奇数个投票节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mongodb文档建议副本集的投票节点数应为奇数.是什么原因呢?

The mongodb documentation suggests that a replica set should have an odd number of voting nodes. What is the reason for this?

推荐答案

让我们想象一个副本集具有偶数个节点(例如4个).然后,不幸的网络分区发生,将集合分成两半(2 + 2).应该接受哪个分区的写入?第一的?第二?两个都?恢复网络后会发生什么?这些都是难题.

Let's imagine that a replica set has even number of nodes (4, for example). Then an unfortunate network partition happens that splits the set in half (2 + 2). Which partition should accept writes? First? Second? Both? What should happen when network is restored? These are all hard questions.

奇数个节点完全消除了问题.该组不能完全分成两半.因此,较大的部分将接受写入(确切地说,节点必须看到超过一半的节点(包括自身)被选为主要节点.因此,它是1,1 of 2、3、3 5、4 7等,依此类推).

Having odd number of nodes eliminates the questions entirely. The set can't be split exactly in half. So the bigger part will accept writes (to be exact, node must see more than half of nodes (including self) to be elected as primary. So it's 1 of 1, 2 of 3, 3 of 5, 4 of 7 and so on).

这篇关于为什么mongodb副本集需要一个奇数个投票节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆