Leader Not Available Kafka in Console Producer

前端 未结 24 2574
野趣味
野趣味 2020-12-07 07:47

I am trying to use Kafka.
All configurations are done properly but when I try to produce message from console I keep getting the following error

WARN Err         


        
24条回答
  •  暖寄归人
    2020-12-07 08:24

    Adding this since it may help others. A Common problem can be a misconfiguration of advertised.host.name. With Docker using docker-compose setting the name of the service inside KAFKA_ADVERTISED_HOST_NAME wont work unless you set the hostname as well. docker-compose.yml example:

      kafka:
        image: wurstmeister/kafka
        ports:
          - "9092:9092"
        hostname: kafka
        environment:
          KAFKA_ADVERTISED_HOST_NAME: kafka
          KAFKA_CREATE_TOPICS: "test:1:1"
          KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock
    

    The above without hostname: kafka can issue a LEADER_NOT_AVAILABLE when trying to connect. You can find an example of a working docker-compose configuration here

提交回复
热议问题