gpt4 book ai didi

java - Apache Kafka 主题元数据获取包含错误 : {LEADER_NOT_AVAILABLE}

转载 作者:行者123 更新时间:2023-12-02 04:16:46 28 4
gpt4 key购买 nike

我正在尝试制作包含 wurstmeister/zookeeper 和 wurstmeister/kafka 的 dockerfile。如果我在计算机上运行消费者和生产者,一切正常(我在终端上运行zookeeper和kafka)。但是当我使用这个zookeper和kafka时,我的意思是当我运行这个dockerfile时,我得到了这个错误

o.a.k.c.consumer.internals.Fetcher - [Consumer clientId=consumer-1, groupId=consumerGroup1] Topic metadata fetch included errors: {log-monitoring=LEADER_NOT_AVAILABLE}

我认为是网络问题,他们在docker上找不到对方。这是我的 docker-compose.yml

zookeeper:
image: wurstmeister/zookeeper
container_name: "zk"
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
container_name: "kafka"
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100
KAFKA_ZOOKEEPER_CONNECT: zk:2181
KAFKA_CREATE_TOPICS: "log-monitoring"
links:
- zookeeper:zk
volumes:
- /var/run/docker.sock:/var/run/docker.sock
mongo:
image: mongo
container_name: "mongo"
ports:
- "27017:27017"

producer:
image: berat703/kafka-producer:0.0.3
container_name: "producer"
environment:
- KAFKA_BROKER=kafka:9092
links:
- kafka:kafka
consumer:
image: berat703/kafka-consumer:0.0.2
container_name: "consumer"
ports:
- "8080:8080"
environment:
- KAFKA_BROKER=kafka:9092
- MONGODB_HOST=mongo
- MONGODB_PORT=27017
links:
- kafka:kafka

最佳答案

尝试将KAFKA_ADVERTISED_HOST_NAME更改为kafka的FQDN,即。卡夫卡。无论你放在那里什么,都需要由生产者来解决。该字段也已弃用,建议使用类似 KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092 的内容。

关于java - Apache Kafka 主题元数据获取包含错误 : {LEADER_NOT_AVAILABLE},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56656428/

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