kafka集群启动报错:ZkTimeoutException 解决办法

搭建的kafka集群启动报错连接zookeeper超时,异常信息:


[2020-08-01 08:55:52,450] INFO Terminate ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2020-08-01 08:55:52,656] INFO Session: 0x0 closed (org.apache.zookeeper.ZooKeeper)
[2020-08-01 08:55:52,656] FATAL Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server 'zk01:2181,zk01:2181,zk01:2181' with timeout of 6000 ms
        at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1233)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:157)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:131)
        at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:103)
        at kafka.utils.ZkUtils$.apply(ZkUtils.scala:85)
        at kafka.server.KafkaServer.initZk(KafkaServer.scala:338)
        at kafka.server.KafkaServer.startup(KafkaServer.scala:191)
        at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
        at kafka.Kafka$.main(Kafka.scala:65)
        at kafka.Kafka.main(Kafka.scala)
[2020-08-01 08:55:52,657] INFO shutting down (kafka.server.KafkaServer)
[2020-08-01 08:55:52,660] INFO shut down completed (kafka.server.KafkaServer)
[2020-08-01 08:55:52,660] FATAL Exiting Kafka. (kafka.server.KafkaServerStartable)
[2020-08-01 08:55:52,662] INFO EventThread shut down for session: 0x0 (org.apache.zookeeper.ClientCnxn)
[2020-08-01 08:55:52,663] INFO shutting down (kafka.server.KafkaServer)

原因:kafka无法连接zookeeper,首先检查了我的集群的hosts里面配置了映射关系,并且是正确的,但是现在报错连接不上,最大的可能就是服务器的防火墙的问题,查看了防火墙的状态果然是打开的。所以执行了下面的操作,kafka集群就可以正常的启动了。


--------- zk01 ----------
16289 Jps
15218 DataNode
16050 Kafka  
15060 NameNode
15717 Application
15563 QuorumPeerMain
15485 NodeManager
--------- zk02 ----------
14853 Kafka
13974 ResourceManager
15030 Jps
14523 Application
13821 DataNode
14141 NodeManager
14365 QuorumPeerMain
--------- zk03 ----------
13569 QuorumPeerMain 
13171 DataNode
13302 SecondaryNameNode
13865 Kafka
13964 Application
14189 Jps
13406 NodeManager
---------------------------------------------------------------------------

解决方案:

1:查看防火墙状态:systemctl status firewalld.service,如果打开了,立即关闭(参考命令:systemctl stop firewalld.service)
1.1: 禁止firewall开机启动:systemctl disable firewalld.service
2:关闭SELinux:vim /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled,设置后需要重启才能生效
posted @ 2020-08-01 09:23  Leo-Wong  阅读(1897)  评论(0编辑  收藏  举报