报错连接zookeeper超时

swhua@swhua:~/Desktop/kafka_2.13-2.7.0$ bin/kafka-topics.sh --create --zookeeper localhost:9092 --replication-factor 1 --partitions 1 --topic matchresult --config cleanup.policy=compact
[2021-05-09 16:56:39,279] WARN Client session timed out, have not heard from server in 30000ms 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)


原因分析:
1.kafka中config目录下的server.properties配置的zookeeper是否错误
2.2181以及9092的端口是否被占用
3.防火墙需要关闭
4.连接zookeeper端口是2181
5.高版本kafka创建主题时的参数不是--zookeeper 而是--bootstrap-server
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐