gpt4 book ai didi

docker - "kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection"仅在列出主题期间

转载 作者:行者123 更新时间:2023-12-02 17:32:38 24 4
gpt4 key购买 nike

我发现了几个主题相似但上下文不同的问题:我可以连接以创建主题,但是无法列出主题,因为我遇到了下面提到的错误(据我所知,人们在我进行基本连接时遇到了问题只列出主题列表)。
万一重要,这是我的docker-compose.yml:

version: "3"
services:
zookeeper:
image: wurstmeister/zookeeper

kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: "localhost"
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
我的控制台:
bash-4.4# kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic test2
Created topic test2.
bash-4.4# kafka-topics.sh --list --zookeeper localhost:2181
Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
at kafka.zookeeper.ZooKeeperClient.$anonfun$waitUntilConnected$3(ZooKeeperClient.scala:259)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:253)
at kafka.zookeeper.ZooKeeperClient.waitUntilConnected(ZooKeeperClient.scala:255)
at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:113)
at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1858)
at kafka.admin.TopicCommand$ZookeeperTopicService$.apply(TopicCommand.scala:321)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:54)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
bash-4.4# kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic test3
Created topic test3.
bash-4.4# kafka-topics.sh --list --zookeeper localhost:2181
Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
at kafka.zookeeper.ZooKeeperClient.$anonfun$waitUntilConnected$3(ZooKeeperClient.scala:259)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:253)
at kafka.zookeeper.ZooKeeperClient.waitUntilConnected(ZooKeeperClient.scala:255)
at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:113)
at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1858)
at kafka.admin.TopicCommand$ZookeeperTopicService$.apply(TopicCommand.scala:321)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:54)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
bash-4.4#
已编辑
我可能会发现将来的读者很有用,因为我可以直接从Docker Kafka容器中列出所有主题,而无需登录Docker Zookeper容器( https://stackoverflow.com/a/56595227/4148175)
C:\Users\>docker exec -it test1_kafka_1 bash

bash-4.4# kafka-topics.sh --list --bootstrap-server localhost:9092
__consumer_offsets
test2
test3
test_topic
bash-4.4#

最佳答案

--zookeeper zookeeper:2181似乎运行良好
--zookeeper localhost:2181将始终在kafka容器中失败,因为它未运行Zookeeper服务器

注意:latest kafka versions support using --bootstrap-servers instead,因此您可以从kafka容器中使用kafka:9092 localhost:9092

关于docker - "kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection"仅在列出主题期间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59868898/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com