Exception running kafka-console-producer.sh (0.8.1.1)

前端 未结 2 2183
忘掉有多难
忘掉有多难 2021-02-19 06:29

I am trying out the kafka-console-producer.sh. I type something to the console and hit enter and I get tons of stack traces to the console like this. Appreciate any pointers.

相关标签:
2条回答
  • 2021-02-19 07:05

    This is because you are starting your consumer in a wrong way. If you will check the official documentation, you can see that you have to:

    start Zookeper

    bin/zookeeper-server-start.sh config/zookeeper.properties
    

    start Kafka

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

    create a topic

    bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
    

    start producing messages for a topic

    bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test 
    

    Notice the difference: you are connecting to zookeper (port 2181) you need to connect to a broker (port 9092)

    0 讨论(0)
  • 2021-02-19 07:18

    Your broker-list argument is pointing to Zookeeper instead of the actual broker. The proper usage would be:

    ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
    

    assuming your broker runs on port 9092 (default).

    You can refer here for more information (your issue is described in Step 4: Send some messages)

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