Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING

遇到问题:

今天在启动kafka后创建topic时遇到如下错误:

[root@localhost config]# kafka-topics.sh --create --zookeeper 192.168.68.110:2181,192.168.68.111:2181,192.168.68.113:2181 --replication-factor 2 --partitions 3 --topic test
[2022-12-12 14:03:32,215] WARN Client session timed out, have not heard from server in 40053ms for sessionid 0x0 (org.apache.zookeeper.ClientCnxn)
Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
    at kafka.zookeeper.ZooKeeperClient.waitUntilConnected(ZooKeeperClient.scala:262)
    at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:119)
    at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1881)
    at kafka.admin.TopicCommand$ZookeeperTopicService$.apply(TopicCommand.scala:376)
    at kafka.admin.TopicCommand$.main(TopicCommand.scala:57)
    at kafka.admin.TopicCommand.main(TopicCommand.scala)

 

 

问题解决:

这是因为自己已经搭建了zookeeper集群。如果只启动单台服务器zookeeper在选举的时候将不可进行。所以zookeeper就会认为服务处于不可用状态。将node02和node03节点的zookeeper全部启动后创建topic成功

posted @ 2022-12-12 14:12  风夏呀  阅读(1178)  评论(0编辑  收藏  举报