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中的解释:
通常,这是预计会在那里的大多数人, 虽然很多机构的法定人数可能会更低或更高。