为什么卡夫卡会警告“分区的领导者经纪人没有匹配的听众”? [英] Why could Kafka warn "partitions have leader brokers without a matching listener"?

查看:923
本文介绍了为什么卡夫卡会警告“分区的领导者经纪人没有匹配的听众”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图让Kafka首次在docker-compose上工作。该应用程序在没有docker的情况下运行良好。但是在docker上,出现如下所述的错误。为什么卡夫卡会抛出此错误?



错误:


电子邮件-service_1 | 2018-12-01 14:32:02.448警告1 ---
[ntainer#0-0-C-1] oakcNetworkClient:[Consumer
clientId = consumer-2,groupId = kafka] 1分区中的领导者经纪人
没有匹配的侦听器,包括[email-token-0]


我的docker-compose配置:

 版本:'3.3'
服务:
动物园管理员:
图片:wurstmeister / zookeeper
端口:
- 2181:2181

kafka:
图片:wurstmeister / kafka
命令:[start-kafka.sh]
环境:
KAFKA_ZOOKEEPER_CONNECT:zookeeper:2181
KAFKA_ADVERTISED_HOST_NAME:192.168.23.134
KAFKA_CREATE_TOPICS:电子邮件令牌:1:1
数量:
-/ var /run/docker.sock:/var/run/docker.sock
端口:
- 9092:9092
取决于:
-动物园管理员

电子邮件服务:
构建:./电子邮件服务
环境:
SPRING_KAFKA_BOOTSTRAPSERVERS:kafka:90 92
端口:
- 8081:8081
取决于:
-kafka


解决方案

正如您对问题的评论中所述,问题似乎出在Kafka经纪人的广告名称上。根据您的docker-compose,您应该使用 192.168.23.134 ,但是您的电子邮件服务使用的是 kafka:9092 。您可以尝试使用此docker-compose。我用 confluentinc 提供的最新Zookeeper和Kafka替换了wurstmeister服务,并添加了您的电子邮件服务。

  --- 
版本: 2
服务:
动物园管理员:
图片:confluentinc / cp-zookeeper:最新
环境:
ZOOKEEPER_CLIENT_PORT:2181
ZOOKEEPER_TICK_TIME:2000

kafka:
图片:confluentinc / cp -kafka:最新
取决于:
-zookeeper
端口:
-9092:9092
环境:
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_ATION_LIST_LIC_LIC_LIC_LIC_LIC_NAME_LIC_LIC_FREE:

电子邮件服务:
构建:./email-service
环境:
SPRING_KAFKA_BOOTSTRAPSERVERS:kafka:29092
端口:
- 8081:8081
取决于:
-kafka




advertised.listeners :发布到ZooKeeper以便客户端使用的侦听器,如果与侦听器config属性不同。在IaaS环境中,这可能需要与代理绑定的接口不同。如果未设置,将使用侦听器的值。与侦听器不同,它不能宣告0.0.0.0元地址。


请注意, KAFKA_ADVERTISED_HOST_NAME 已过时,建议改用 KAFKA_ADVERTISED_LISTENERS 。有关 KAFKA_ADVERTISED_LISTENERS 的详细信息,请在此处。 / p>

I'm trying to get Kafka to work on docker-compose for the first time. The application runs fine without docker. But on docker, I get the error as described below. Any reason why Kafka would throw this error?

The error:

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]

My docker-compose config:

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

解决方案

As stated in the comments to your question the problem seems to be with the advertised name for the Kafka broker. According to your docker-compose you should be using 192.168.23.134 but your email-service is using kafka:9092. You can try with this docker-compose. I replaced the wurstmeister services with the latest Zookeeper and Kafka provided by confluentinc and added your email-service.

---
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.

Please note that KAFKA_ADVERTISED_HOST_NAME has been deprecated and it's recommended to use KAFKA_ADVERTISED_LISTENERS instead. For more information about KAFKA_ADVERTISED_LISTENERS check here.

这篇关于为什么卡夫卡会警告“分区的领导者经纪人没有匹配的听众”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆