Leader Not Available Kafka in Console Producer

前端 未结 24 2530
野趣味
野趣味 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:14

    I have been witnessing this same issue in the last 2 weeks while working with Kafka and have been reading this Stackoverflow's post ever since.

    After 2 weeks of analysis i have deduced that in my case this happens when trying to produce messages to a topic that doesn't exist.

    The outcome in my case is that Kafka sends an error message back but creates, at the same time, the topic that did not exist before. So if I try to produce any message again to that topic after this event, the error will not appear anymore as the topic as been created.

    PLEASE NOTE: It could be that my particular Kafka installation was configured to automatically create the topic when the same does not exist; that should explain why in my case I can see the issue only once for every topic after resetting the topics: your configuration might be different and in that case you would keep receiving the same error over and over.

    Regards,

    Luca Tampellini

    0 讨论(0)
  • 2020-12-07 08:14

    Issue is resolved after adding the listener setting on server.properties file located at config directory. listeners=PLAINTEXT://localhost(or your server):9092 Restart kafka after this change. Version used 2.11

    0 讨论(0)
  • 2020-12-07 08:15

    If you are running kafka on local machine, try updating $KAFKA_DIR/config/server.properties with below line: listeners=PLAINTEXT://localhost:9092 and then restarting kafka.

    0 讨论(0)
  • 2020-12-07 08:17

    I'm using kafka_2.12-0.10.2.1:

    vi config/server.properties

    add below line:

    listeners=PLAINTEXT://localhost:9092
    
    • No need to change the advertised.listeners as it picks up the value from std listener property.

    Hostname and port the broker will advertise to producers and consumers. If not set,

    • it uses the value for "listeners" if configured

    Otherwise, it will use the value returned from java.net.InetAddress.getCanonicalHostName().

    stop the Kafka broker:

    bin/kafka-server-stop.sh
    

    restart broker:

    bin/kafka-server-start.sh -daemon config/server.properties
    

    and now you should not see any issues.

    0 讨论(0)
  • 2020-12-07 08:17

    I am using docker-compose to build the Kafka container using wurstmeister/kafka image. Adding KAFKA_ADVERTISED_PORT: 9092 property to my docker-compose file solved this error for me.

    0 讨论(0)
  • 2020-12-07 08:17

    For all those struggling with the Kafka ssl setup and seeing this LEADER_NOT_AVAILABLE error. One of the reasons that might be broken is the keystore and truststore. In the keystore you need to have private key of the server + signed server certificate. In the client truststore, you need to have intermedidate CA certificate so that client can authenticate the kafka server. If you will use ssl for interbroker communication, you need this truststore also set in the server.properties of the brokers so they can authenticate each other.

    That last piece I was mistakenly missing and caused me a lot of painful hours finding out what this LEADER_NOT_AVAILABLE error might mean. Hopefully this can help somebody.

    0 讨论(0)
提交回复
热议问题