为什么在MongoDB复制中需要一个“仲裁者"? [英] Why do we need an 'arbiter' in MongoDB replication?

查看:93
本文介绍了为什么在MongoDB复制中需要一个“仲裁者"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们设置了一个没有仲裁器的MongoDB复制,如果主数据库不可用,则副本集将选择一个辅助数据库因此,我认为这是隐式仲裁器,因为副本将自动选择一个主要仲裁器.

Assume we setup a MongoDB replication without arbiter, If the primary is unavailable, the replica set will elect a secondary to be primary. So I think it's kind of implicit arbiter, since the replica will elect a primary automatically.

所以我想知道为什么我们需要一个专用的仲裁器节点?谢谢!

So I am wondering why do we need a dedicated arbiter node? Thanks!

推荐答案

创建了一个电子表格,以更好地说明副本集中仲裁节点的效果.

I created a spreadsheet to better illustrate the effect of Arbiter nodes in a Replica Set.

基本上可以归结为以下几点:

It basically comes down to these points:

  1. RS的 2个数据节点中,丢失1台服务器会使您低于最低投票数(大于N/2").仲裁员可以解决这个问题.
  2. 对于具有个偶数数据节点的RS,添加仲裁器会使您的容错能力提高1,而不会因分裂而导致2个投票集群.
  3. 具有编号为奇数个数据节点的RS ,添加仲裁器将允许拆分创建2个具有大于N/2"票的孤立群集,从而实现裂脑方案.
  1. With an RS of 2 data nodes, losing 1 server brings you below your voting minimum (which is "greater than N/2"). An arbiter solves this.
  2. With an RS of even numbered data nodes, adding an Arbiter increases your fault tolerance by 1 without making it possible to have 2 voting clusters due to a split.
  3. With an RS of odd numbered data nodes, adding an Arbiter would allow a split to create 2 isolated clusters with "greater than N/2" votes and therefore a split brain scenario.

对选举进行了详细的解释,解释它是如何工作的.对我来说,似乎如果你有一个分裂发生在一侧4名成员(所有的投票权)和46元(3投票),另一方面,你宁愿有46选出一所小学和4是一个只读仅群集.但是,这正是有限投票"所防止的.在这种情况下,您实际上将拥有一个具有主要成员的4成员集群和一个只读的46成员集群.解释其合理性超出了这个问题的范围,而且超出了我的了解.

Elections are explained [in poor] detail here. In that document it states that an RS can have 50 members (even number) and 7 voting members. I emphasize "states" because it does not explain how it works. To me it seems that if you have a split happen with 4 members (all voting) on one side and 46 members (3 voting) on the other, you'd rather have the 46 elect a primary and the 4 to be a read-only cluster. But, that's exactly what "limited voting" prevents. In that situation you will actually have a 4 member cluster with a primary and a 46 member cluster that is read only. Explaining how that makes sense is out of the scope of this question and beyond my knowledge.

这篇关于为什么在MongoDB复制中需要一个“仲裁者"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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