我想设置版本为3.5.1的3节点zookeeper群集。为了将它部署到kubernetes,我必须使zookeeper节点本身为0.0.0.0,因此它可以正确启动。配置如下:
ZK1 : zoo.cfg
standaloneEnabled=false
dynamicConfigFile=/opt/zookeeper/conf/zoo.cfg.dynamic
zoo.cfg.dynamic
server.1=0.0.0.0:2888:3888:participant;2181
server.2=10.62.56.192:2889:3889:participant;2182
server.3=10.62.56.192:2890:3890:participant;2183
ZK2 : zoo.cfg
standaloneEnabled=false
dynamicConfigFile=/opt/zookeeper/conf/zoo.cfg.dynamic
zoo.cfg.dynamic
server.1=10.62.56.192:2888:3888:participant;2181
server.2=0.0.0.0:2889:3889:participant;2182
server.3=10.62.56.192:2890:3890:participant;2183
ZK3 : zoo.cfg
standaloneEnabled=false
dynamicConfigFile=/opt/zookeeper/conf/zoo.cfg.dynamic
zoo.cfg.dynamic
server.1=10.62.56.192:2888:3888:participant;2181
server.2=10.62.56.192:2889:3889:participant;2182
server.3=0.0.0.0:2890:3890:participant;2183
结果只能启动zk1,zk2和zk3无法启动。错误是
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: client address for this server (id = 2) in static config file is 0.0.0.0/0.0.0.0:2181 is different from client address found in dynamic file: /0.0.0.0:2182
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.setupClientPort(QuorumPeerConfig.java:608)
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.setupQuorumPeerConfig(QuorumPeerConfig.java:506)
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:157)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:110)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:79)
配置无效,异常退出
关键是我们必须将节点本身配置为0.0.0.0。
答案 0 :(得分:0)
尝试:https://hub.docker.com/r/elevy/zookeeper/基于https://github.com/eliaslevy/docker-zookeeper
每个zk pod使用1个服务。每个服务都有自己的“主机名”,可以通过DNS从每个zk pod中解析。名称是zookeeper-1,zookeeper-2和zookeeper-3。
所以,而不是像
这样的配置行server.1=0.0.0.0:2888:3888:participant;2181
server.2=10.62.56.192:2889:3889:participant;2182
server.3=10.62.56.192:2890:3890:participant;2183
你有如下的配置行:
server.1=zookeeper-1:2888:3888
server.2=zookeeper-2:2888:3888
server.3=zookeeper-3:2888:3888
请注意,由于每个Pod都有自己的IP,因此您无需使用一系列端口,例如2888,2889,2890。您可以为每个端口使用2888/3888。