当主人倒下时,动物园管理员怎么办 [英] how does zookeeper do when the master down

查看:78
本文介绍了当主人倒下时,动物园管理员怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题看起来很傻,但是尽管我读了很多有关Zookeeper的文档,但是当主服务器停机时,我真的不明白Zookeeper的故障转移策略.我的问题如下:

The title may look like silly, but I really can't understand the zookeeper failover policy when the master is down although I read a lot of docs about Zookeeper. My question as following:

  1. 如果我有三个节点的zookeeper,则说明主节点已关闭,该怎么办其余两个节点选出新的主节点(现在是偶数数字节点,如何按多数投票).
  2. 如果剩余之一向下两个节点,那么最后一个将成为主节点并不断服务该服务,好吗?
  3. 如果偶数动物园管理员节点可以运行得很好,为什么我必须设置奇数个Zookeeper节点?

推荐答案

  1. 我认为您误会了我们在这里谈论的多数.重要的多数不在其余节点中,而是在整个群集中.因此,您需要问的是:"2个节点能否在3个节点中占多数"?答案是他们可以,因此他们可以选举领导人.(我不完全知道Zookeeper如何解决领导者投票问题,但重要的是节点的目标不是成为领导者,而是决定一名领导者.要说服您,这可能是一种简单(但缓慢)的方式解决问题的方法:节点随机投票,如果形成多数,则选举该领导人,然后再次投票.)

  1. I think you're misunderstanding what majority we're talking about here. The majority that is important is not among the remaining nodes, but among the entire cluster. So what you need to ask is: 'Can 2 nodes form a majority among 3 nodes'? And the answer is that they can, and therefore they can elect a leader. (I do not know exactly how Zookeeper solves leader voting, but the important thing is that the goals for the nodes is not to become leader but to decide on one leader. And to convince you it's possible here's a vary simple (but slow) way of solving it: The nodes vote at random, if they have formed a majority they elect that leader else they vote again.)

否,情况并非如此.由于群集仍配置为三节点群集,因此剩下的一个节点无法形成多数,因此无法选举领导者.这就是为什么如果其中一个节点掉线,则2节点集群实际上比1节点集群更糟的原因之一.

No, this will not be the case. Since the cluster is still configured around being a 3 node cluster the one node that is left can not form a majority and can therefor not elect a leader. This is one of the reasons why a 2 node cluster can actually be worse then a 1 node one, if one of the nodes go down the cluster stops.

您不必这样做,它只是建议.拥有奇数的一个很好的理由是,如果您得到一个将您的集群分为相同大小的两个部分的网状分割,则任何一方都不能选出一个领导者.(如果运行的节点数为奇数,则不可能.)您也可以将其视为买一送一"的交易类型,如果您有4个节点,那么只有1个可以下降,但是如果有5个节点,则2个可以下降.但是,如果您有6个节点,那么在群集不关闭的情况下仍然只有2个节点可以关闭.

You do not have to, it is just recommended. And a good reason to have a odd number is that if you get a net-split that divides your cluster into two parts of same size no side can elect a leader. (This is not possible if you run a odd number of nodes.) You can also see it as a buy-one-get-one-free type of deal, if you have 4 nodes only 1 can go down, but if you get 5 nodes it's okay for 2 to go down. But if you get 6 nodes it's still just 2 nodes that can go down without the cluster going down.

这篇关于当主人倒下时,动物园管理员怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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