ZooKeeper可靠性 - 三个节点与五个节点

时间:2012-10-23 01:11:31

标签: zookeeper apache-zookeeper

来自ZooKeeper FAQ

Reliability:

A single ZooKeeper server (standalone) is essentially a coordinator with
no reliability (a single serving node failure brings down the ZK service).

A 3 server ensemble (you need to jump to 3 and not 2 because ZK works
based on simple majority voting) allows for a single server to fail and
the service will still be available.

So if you want reliability go with at least 3. We typically recommend
having 5 servers in "online" production serving environments. This allows
you to take 1 server out of service (say planned maintenance) and still
be able to sustain an unexpected outage of one of the remaining servers
w/o interruption of the service.

使用3服务器集合,如果一台服务器退出轮换并且一台服务器出现意外中断,则仍有一台服务器应确保不会中断服务。那为什么需要5台服务器?或者这不仅仅是正在考虑的服务中断?

更新

感谢@sbridges指出它与维持法定人数有关。 ZK定义法定人数的方式是ceil(N/2),其中N是整体中的原始号码(而不仅仅是当前可用的集合)。

现在,谷歌搜索ZK法定人数在HBase书chapter on ZK中找到了这个:

  

在ZooKeeper中,支持偶数个对等体,但通常是这样   不使用,因为偶数大小的合奏需要按比例增加   同等形成法定人数而不是奇数大小的合奏需要。对于   例如,一个有4个对等体的集合需要3来形成一个法定人数   与5合奏也需要3来形成法定人数。因此,一个合奏   5允许2个对等体失败并仍然维持法定人数,因此更多   比4的整体容错,只允许1个对等。

这是维基百科在Edward J. Yoon的blog中的解释:

  

通常,这是预计会在那里的大多数人,   虽然很多机构的法定人数可能会更低或更高。

2 个答案:

答案 0 :(得分:25)

Zookeeper要求您拥有法定数量的服务器,其中仲裁为ceil(N/2)。对于3服务器集合,这意味着2台服务器必须随时启动,对于5台服务器集合,3台服务器需要随时启动。

答案 1 :(得分:2)

与失败的Zookeeper相比,只要Active Zookeeper处于紧急状态,Zookeeper基本上可以正常工作。 同样,在法定人数相等的情况下,即2,4,6等。失败=有效,因此不建议这样做。

3和4只能处理1种疾病,为什么我们要使用4个Zookeeper而不是3个?

enter image description here