我采用的是CentOS7操作系统安装zookeeper,我的配置没有问题,三个节点启动后(./zkServer.sh start),用jps查看进程,QuorumPeerMain进程都正常启动
但是
zkServer.sh status 查看状态时,显示的是Error contacting service. It is probably not running.
查看了配置文件和myid,仍然看不出啥问题,后面想着看日志,可是不知道日志在哪里看。
网上看到一篇zookeeper环境搭建中的几个坑[Error contacting service. It is probably not running]的分析及解决
这篇博文提到可以通过
以start-foreground方式启动,会看到启动日志
故采用此命令执行 ./zkServer.sh start-foreground
然后终端就输出以下提示错误:
2017-06-20 10:54:57,691 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@588] - Cannot open channel to 2 at election address centos06/192.168.3.9:3888
java.net.NoRouteToHostException: 没有到主机的路由
百度了下,说可能是linux系统的防火前没有关闭,所以我就把三个节点的防火墙关闭了
以下是centos关闭防火墙的正确方式:
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
关闭防火墙之后,我的zookeeper就正常了
[yellow@centos05 bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/yellow/app/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower
[yellow@centos05 bin]$
ZooKeeper JMX enabled by default
Using config: /home/yellow/app/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: leader
[yellow@centos06 bin]$
[yellow@centos07 bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/yellow/app/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower