docker schema registry 和 kafka rest 无法启动

docker schema registry and kafka rest cannot up

zookeeper 和 Kafka 都沟通的很好 运行.

不确定为什么架构注册中心和 Kafka 休息无法启动。

下面是 docker-compose 文件。

这是架构和其余 docker-compose 文件。 关于这个 docker

的错误
[main] ERROR io.confluent.admin.utils.cli.KafkaReadyCommand - Error while running kafka-ready.
java.lang.RuntimeException: No endpoints found for security protocol [PLAINTEXT]. Endpoints found in ZK [{EXTERNAL=localhost:9092, INTERNAL=kafka:29092}]
        at io.confluent.admin.utils.cli.KafkaReadyCommand.main(KafkaReadyCommand.java:143)



[main] INFO org.apache.zookeeper.ZooKeeper - Session: 0x1003f4a8fa10006 closed
[main] ERROR io.confluent.admin.utils.cli.KafkaReadyCommand - Error while running kafka-ready.
java.lang.RuntimeException: No endpoints found for security protocol [PLAINTEXT]. Endpoints found in ZK [{EXTERNAL=localhost:9092, INTERNAL=kafka:29092}]
        at io.confluent.admin.utils.cli.KafkaReadyCommand.main(KafkaReadyCommand.java:143)

Docker 撰写:

schema-registry:
    network_mode: pm
    image: confluentinc/cp-schema-registry:5.2.1
    hostname: schema-registry
    container_name: schema-registry
    depends_on:
      - zookeeper
      - kafka
    ports:
      - "8081:8081"
    environment:
      SCHEMA_REGISTRY_HOST_NAME: 'schema-registry'
      SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'
      SCHEMA_REGISTRY_LISTENERS: "http://schema-registry:8081"

  rest-proxy:
    network_mode: pm
    image: confluentinc/cp-kafka-rest:5.2.1
    depends_on:
      - zookeeper
      - kafka
      - schema-registry
    ports:
      - "8082:8082"
    hostname: rest-proxy
    container_name: rest-proxy
    environment:
      KAFKA_REST_HOST_NAME: 'rest-proxy'
      KAFKA_REST_BOOTSTRAP_SERVERS: 'kafka:29092'
      KAFKA_REST_LISTENERS: "http://rest-proxy:8082"
      KAFKA_REST_SCHEMA_REGISTRY_URL: 'http://schema-registry:8081'
      KAFKA_REST_ZOOKEEPER_CONNECT: 'zookeeper:2181' 

这是 zk 和 kafka docker 组合

  zookeeper:
    network_mode: pm
    image: wurstmeister/zookeeper
    hostname: zookeeper
    container_name: zookeeper
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
      ALLOW_ANONYMOUS_LOGIN: 1

  kafka:
    network_mode: pm
    image: wurstmeister/kafka
    hostname: kafka
    container_name: kafka
    depends_on:
      - zookeeper
    ports:
      - "9092:9092"
    environment:
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
      ALLOW_PLAINTEXT_LISTENER: 'yes'
      KAFKA_ADVERTISED_HOST_NAME: kafka
      KAFKA_LISTENERS: "INTERNAL://:29092,EXTERNAL://:9092"
      KAFKA_ADVERTISED_LISTENERS: "INTERNAL://kafka:29092,EXTERNAL://localhost:9092"
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT"
      KAFKA_INTER_BROKER_LISTENER_NAME: "INTERNAL"
      KAFKA_ZOOKEEPER_SESSION_TIMEOUT: "6000"
      KAFKA_RESTART_ATTEMPTS: "10"
      KAFKA_RESTART_DELAY: "5"
      ZOOKEEPER_AUTOPURGE_PURGE_INTERVAL: "0"

它无法启动,因为它不知道您正尝试连接到两个侦听器中的哪一个。这不能通过提供 ZK 地址 AFAIK 来确定。无论如何,除了 Kafka 之外,您不需要 Zookeeper。

例如,您可以使用 existing all-in-one compose file for Confluent

特别注意 REST 代理没有 ZK

https://github.com/confluentinc/cp-all-in-one/blob/5.5.0-post/cp-all-in-one-community/docker-compose.yml#L139-L143

对于架构注册表:https://docs.confluent.io/current/schema-registry/installation/deployment.html#ak-based-primary-election

我在 kafka docker 环境中通过正确的配置得到了它。

环境:

KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'

KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'

ALLOW_PLAINTEXT_LISTENER: 'yes'

KAFKA_LISTENERS: 纯文本://:9092

KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092

另外kafdrop配置不需要使用29092,只需要使用默认的kafka端口9092即可。

KAFKA_BROKERCONNECT: "kafka:9092"