10

I'm trying to set up Apache Kafka to communicate between two virtual machines running CentOS on the same network. I originally set up a Kafka producer and consumer on one machine and everything was running smoothly. I then set up Kafka on the other machine and in the process of trying to get them to connect, I get the error "bootstrap-server is not a recognized option" (I'm running the most recent version of Kafka, 2.2).

This is what I used to attempt a producer connection:

bin/kafka-console-producer.sh --bootstrap-server 10.0.0.11:9092 --topic test

And on the consumer side:

bin/kafka-console-producer.sh --bootstrap-server 10.0.0.11:9092 --topic test

The 10.0.0.11 machine is running the server itself.

1
  • It's not until Kafka 2.5.0, console producer accepts --bootstrap-server, before this version, use --broker-list.
    – michaelliu
    May 16, 2020 at 7:11

3 Answers 3

16

According do Apache Kafka Documentation, that can be found here: https://kafka.apache.org/documentation/#quickstart_send, you should use --broker-list property to pass broker address.

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

EDIT

From Apache Kafka 2.5 both options are supported --broker-list and --bootstrap-server. Suggested one is --bootstrap-server

10
  • 2
    On the consumer side, it tells me "--broker-list is not a recognized option" May 8, 2019 at 17:59
  • 2
    @AbigailFox, for consumer is --bootstrap-server, for producer: --broker-list May 8, 2019 at 18:00
  • 1
    my consumer gives me the bootstrap-server error as well. broker-list fixes it for the producer side, but the consumer side still does not work May 8, 2019 at 18:01
  • 1
    @AbigailFox In the question there is only producer side, that should work after changing property May 8, 2019 at 18:25
  • 1
    If the brokers are on remote machines, the advertised listeners property would need fixing May 9, 2019 at 0:13
7

Following command should work.

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

./kafka-console-consumer.sh --zookeeper localhost:2181 --topic fred

Simply giving this command worked. However in upcoming major release using the option bootstrap-server will be mandatory.

When I use the above command it gives a warning: "Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper]."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.