ApacheKafka主题元数据获取包含错误:{leader\u not\u available}

pkmbmrz7  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(363)

我在做dockerfile,里面有wurstmeister/zookeeper和wurstmeister/kafka。如果我在电脑上运行consumer和producer,一切都正常(我在终端上运行zookeeper和kafka),但是当我使用这个zookeeper和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-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
11dmarpk

11dmarpk1#

尝试改变 KAFKA_ADVERTISED_HOST_NAME Kafka的fqdn ie。 kafka . 你放在那里的任何东西都需要制作人来解决。该字段也已弃用,建议使用 KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092 相反。

相关问题