本文目录
0. 概要
本文旨在记录自己在安装 Zookeeper
集群过程中遇到的问题的一些记录。
Linux
服务器3台、5台、7台、(2*n+1),始终有一个 leader
,node/2+1
个节点有效运行,Zookeeper
集群的工作是超过半数才能对外提供服务。
1. 安装过程zookeeper集群
具体过程就不再赘述了, 可以参考这篇博客。
https://www.cnblogs.com/subendong/p/7440558.html
下面我记录一下我在配置过程中遇到的问题。
2. 查看 zookeeper.out 日志文件
2.1 报错内容
WARN [WorkerSender[myid=1]:QuorumCnxManager@584] - Cannot open channel to 2 at election address yourhostname/yourip:13888
问题可以总结为:
Zookeeper error: Cannot open channel to X at election address
2.2 解决方法
首先, 可以看看是不是防火墙的问题, 可能拦截了你在zoo.cfg里面配置的端口
可以关防火墙,关闭防火墙方法:sudo service iptables stop
关闭自启动方法:sudo chkconfig iptables off
如果不是防火墙的问题, 那么可以尝试下面的方案
在*
上, 歪果仁给出了解决方法。
把对应节点在 zoo.cfg
中的 ip
设置为 0.0.0.0
Zookeeper节点1
#Before modification
[zookeeper1]$ tail -3 $ZOOKEEPER_HOME/conf/zoo.cfg
server.1=zookeeper1:12888:13888
server.2=zookeeper2:12888:13888
server.3=zookeeper3:12888:13888
#After modification
[zookeeper1]$ tail -3 $ZOOKEEPER_HOME/conf/zoo.cfg
server.1=0.0.0.0:12888:13888
server.2=zookeeper2:12888:13888
server.3=zookeeper3:12888:13888
Zookeeper节点2
#Before modification
[zookeeper2]$ tail -3 $ZOOKEEPER_HOME/conf/zoo.cfg
server.1=zookeeper1:12888:13888
server.2=zookeeper2:12888:13888
server.3=zookeeper3:12888:13888
#After modification
[zookeeper2]$ tail -3 $ZOOKEEPER_HOME/conf/zoo.cfg
server.1=zookeeper1:12888:13888
server.2=0.0.0.0:12888:13888
server.3=zookeeper3:12888:13888
Zookeeper节点3
#Before modification
[zookeeper3]$ tail -3 $ZOOKEEPER_HOME/conf/zoo.cfg
server.1=zookeeper1:12888:13888
server.2=zookeeper2:12888:13888
server.3=zookeeper3:12888:13888
#After modification
[zookeeper3]$ tail -3 $ZOOKEEPER_HOME/conf/zoo.cfg
server.1=zookeeper1:12888:13888
server.2=zookeeper2:12888:13888
server.3=0.0.0.0:12888:13888
Ending !!! 把对应每个server对应的 server.id 的ip设置为 0.0.0.0
zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower
zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: leader
zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower