docker swarm中连接kafka多代理时出现debezium错误

yacmzcpb  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(581)

当我用这个堆栈建立我的群时:kafka(多代理)、zookeeper、debezium。kafka和zookeeper正在工作,可以创建主题、使用者和生产者,但是debezium显示错误:org.apache.kafka.connect.errors.connectexception:无法连接到和描述kafka集群。检查工作者的代理连接和安全属性。我没有修改任何东西,只是默认配置为下面的docker堆栈:

version: '3.6'
services:
   zoo:
      image: wurstmeister/zookeeper
      ports:
         - '2181:2181'
      volumes:
         - zoo-data:/tmp/zookeeper
      deploy:
         replicas: 1
         placement:
            constraints:
               - node.labels.type==zoo
   kafka:
      image: wurstmeister/kafka:latest
      ports:
         - target: 9094
           published: 9094
           protocol: tcp
           mode: host
      environment:
         HOSTNAME_COMMAND: "docker info | grep ^Name: | cut -d' ' -f 2"
         KAFKA_ZOOKEEPER_CONNECT: zoo:2181
         KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
         KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://_{HOSTNAME_COMMAND}:9094
         KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9094
         KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
         #KAFKA_CREATE_TOPICS: "Topic1:1:2,Topic2:1:1:compact"
      volumes:
         - /var/run/docker.sock:/var/run/docker.sock
         - kafka-data:/tmp/kafka-logs
      deploy:
         mode: global
         placement:
            constraints:
               - node.labels.name==kafka
      depends_on:
         - zoo

   debezium:
      image: debezium/connect:0.8
      hostname: connect
      ports:
         - '8083:8083'
      environment:
         BOOTSTRAP_SERVERS: kafka:9094
         GROUP_ID: 1
         CONFIG_STORAGE_TOPIC: my_connect_configs
         OFFSET_STORAGE_TOPIC: my_connect_offsets
      deploy:
         placement:
            constraints:
               - node.labels.type==dbz
      depends_on:
         - kafka
volumes:
   kafka-data:
   zoo-data:

当我检查docker服务日志debezium时,它显示错误

shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    | 2018-08-03 04:33:27,034 ERROR  ||  Stopping due to error   [org.apache.kafka.connect.cli.ConnectDistributed]
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    | org.apache.kafka.connect.errors.ConnectException: Failed to connect to and describe Kafka cluster. Check worker's broker connection and security properties.
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    at org.apache.kafka.connect.util.ConnectUtils.lookupKafkaClusterId(ConnectUtils.java:64)
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    at org.apache.kafka.connect.util.ConnectUtils.lookupKafkaClusterId(ConnectUtils.java:45)
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    at org.apache.kafka.connect.cli.ConnectDistributed.main(ConnectDistributed.java:77)
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    | Caused by: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Timed out waiting to send the call.
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    at org.apache.kafka.common.internals.KafkaFutureImpl.wrapAndThrow(KafkaFutureImpl.java:45)
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    at org.apache.kafka.common.internals.KafkaFutureImpl.access$000(KafkaFutureImpl.java:32)
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    at org.apache.kafka.common.internals.KafkaFutureImpl$SingleWaiter.await(KafkaFutureImpl.java:89)
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    at org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:258)
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    at org.apache.kafka.connect.util.ConnectUtils.lookupKafkaClusterId(ConnectUtils.java:58)
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    |    ... 2 more
shippo_kafka_debezium.1.5l1yhz27r6p2@kafka1    | Caused by: org.apache.kafka.common.errors.TimeoutException: Timed out waiting to send the call.

有人能告诉我如何修复这个错误吗,我对这个堆栈还不熟悉,所以,在几天的研究中,我搞不懂它。非常感谢!

igsr9ssn

igsr9ssn1#

你可以换这条线 HOSTNAME_COMMAND: "docker info | grep ^Name: | cut -d' ' -f 2"HOSTNAME_COMMAND: "docker info | grep 'Node Address:' | cut -d' ' -f 4" 或者你可以使用这个docker文件

version: '3.2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
    deploy:
       mode: global
    volumes:
      - /shared_data/zoo1/data:/data
      - /shared_data/zoo1/datalog:/datalog
    environment:
        ZOO_MY_ID: 1
        ZOO_PORT: 2181
        ZOO_SERVERS: server.1=zookeeper:2888:3888

  kafka:
    image: wurstmeister/kafka:latest
    ports:
      - target: 9094
        published: 9094
        protocol: tcp
        mode: host
    deploy:
      mode: global
    environment:
      HOSTNAME_COMMAND: "docker info | grep 'Node Address:' | cut -d' ' -f 4"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://_{HOSTNAME_COMMAND}:9094
      KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9094
      KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /shared_data/kafka:/var/lib/kafka/data
    depends_on:
      - zookeeper

相关问题