gpt4 book ai didi

docker - 为什么 Kafka 会警告 "partitions have leader brokers without a matching listener"?

转载 作者:IT老高 更新时间:2023-10-28 21:22:45 25 4
gpt4 key购买 nike

我正在尝试让 Kafka 第一次在 docker-compose 上工作。应用程序在没有 docker 的情况下运行良好。但是在 docker 上,我得到了如下所述的错误。卡夫卡为什么会抛出这个错误?

错误:

email-service_1 | 2018-12-01 14:32:02.448 WARN 1 --- [ntainer#0-0-C-1] o.a.k.c.NetworkClient : [Consumer clientId=consumer-2, groupId=kafka] 1 partitions have leader brokers without a matching listener, including [email-token-0]

我的 docker-compose 配置:

version: '3.3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"

kafka:
image: wurstmeister/kafka
command: [start-kafka.sh]
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_HOST_NAME: 192.168.23.134
KAFKA_CREATE_TOPICS: "email-token:1:1"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "9092:9092"
depends_on:
- zookeeper

email-service:
build: ./email-service
environment:
SPRING_KAFKA_BOOTSTRAPSERVERS: kafka:9092
ports:
- "8081:8081"
depends_on:
- kafka

最佳答案

正如您对问题的评论中所述,问题似乎与 Kafka 代理的广告名称有关。根据您的 docker-compose,您应该使用 192.168.23.134,但您的电子邮件服务使用的是 kafka:9092。你可以试试这个 docker-compose。我用 confluentinc 提供的最新 Zookeeper 和 Kafka 替换了 wurstmeister 服务,并添加了您的电子邮件服务。

---
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000

kafka:
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
ports:
- 9092:9092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

email-service:
build: ./email-service
environment:
SPRING_KAFKA_BOOTSTRAPSERVERS: kafka:29092
ports:
- "8081:8081"
depends_on:
- kafka

advertised.listeners: Listeners to publish to ZooKeeper for clients to use, if different than the listeners config property. In IaaS environments, this may need to be different from the interface to which the broker binds. If this is not set, the value for listeners will be used. Unlike listeners it is not valid to advertise the 0.0.0.0 meta-address.

请注意,KAFKA_ADVERTISED_HOST_NAME 已被弃用,建议改用 KAFKA_ADVERTISED_LISTENERS。有关KAFKA_ADVERTISED_LISTENERS 的更多信息,请查看here .

关于docker - 为什么 Kafka 会警告 "partitions have leader brokers without a matching listener"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53571823/

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