简体   繁体   English

无法将Kafka连接到Zookeeper

[英]Can't connect Kafka to Zookeeper

From docker-compose I got this yml: 从docker-compose我得到了这个yml:

version: '2'
services:
  zookeeper:
    container_name: zookeeper
    image: confluentinc/cp-zookeeper:3.1.1
    ports:
      - "2080:2080"
    environment:
      - ZOOKEEPER_CLIENT_PORT=2080
      - ZOOKEEPER_TICK_TIME=2000

  kafka:
    container_name: kafka
    image: confluentinc/cp-kafka:3.1.1
    ports:
      - "9092:9092"
    environment:
      - KAFKA_CREATE_TOPICS=Topic1:1
      - KAFKA_ZOOKEEPER_CONNECT=192.168.99.100:2080
      - KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.99.100:9092
    depends_on:
      - zookeeper

  schema-registry:
    container_name: schema-registry
    image: confluentinc/cp-schema-registry:3.1.1
    ports:
      - "8081:8081"
    environment:
      - SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=192.168.99.100:2080
      - SCHEMA_REGISTRY_HOST_NAME=localhost
    depends_on:
      - zookeeper
      - kafka

When I stand up this docker the console output ends with: 当我站起这个泊坞窗时,控制台输出以以下结尾:

schema-registry | Error while running kafka-ready.
schema-registry | org.apache.kafka.common.errors.TimeoutException: Timed out waiting for Kafka to create /brokers/ids in Zookeeper. timeout (ms) = 40000
schema-registry exited with code 1

It seems like kafka never connect Zookeper or something like that, does anyone knows why this is happening? 好像卡夫卡从来没有连接过Zookeper或类似的东西,有人知道为什么会这样吗?

Does changing 是否改变

SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=192.168.99.100:2080

into

SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zookeeper:2080

help? 救命?

Additionally, KAFKA_ZOOKEEPER_CONNECT=192.168.99.100:2080 should mention zookeeper as well, instead of an IP address. 此外, KAFKA_ZOOKEEPER_CONNECT=192.168.99.100:2080应该提到zookeeper为好,而不是IP地址。 Or, how can you be sure of that IP address? 或者,您如何确定该IP地址?

KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.99.100:9092 mentions an IP address you might not be able to guarantee as well. KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.99.100:9092提到您可能也无法保证的IP地址。 For the latter, that IP address could be changed into kafka . 对于后者,可以将该IP地址更改为kafka

I also had challenges in getting Kafka and Zookeeper to work in Docker (via Docker Compose). 在使Kafka和Zookeeper在Docker中工作(通过Docker Compose)时,我也遇到了挑战。 In the end, https://github.com/confluentinc/cp-docker-images/blob/5.0.0-post/examples/kafka-single-node/docker-compose.yml worked for me. 最后, https://github.com/confluentinc/cp-docker-images/blob/5.0.0-post/examples/kafka-single-node/docker-compose.yml对我有用。 You could use that as a source of inspiration. 您可以将其用作灵感来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM