Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka bootstrap-servers vs zookeeper in kafka-console-consumer

I'm trying to test run a single Kafka node with 3 brokers & zookeeper. I wish to test using the console tools. I run the producer as such:

kafka-console-producer --broker-list localhost:9092,localhost:9093,localhost:9094 --topic testTopic

Then I run the consumer as such:

kafka-console-consumer --zookeeper localhost:2181 --topic testTopic --from-beginning

And I can enter messages in the producer and see them in the consumer, as expected. However, when I run the updated version of the consumer using bootstrap-server, I get nothing. E.g

kafka-console-consumer --bootstrap-server localhost:9092,localhost:9093,localhost:9094 --topic testTopic --from-beginning

This worked fine when I had one broker running on port 9092 so I'm thoroughly confused. Is there a way I can see what zookeeper is providing as the bootstrap server? Is the bootstrap server different from the broker list? Kafka compiled with Scala 2.11.

like image 871
nico Avatar asked Jan 21 '17 00:01

nico


People also ask

Does Kafka consumer need ZooKeeper?

For the latest version (2.4. 1) ZooKeeper is still required for running Kafka, but in the near future, ZooKeeper dependency will be removed from Apache Kafka. See the high-level discussion in KIP-500: Replace ZooKeeper with a Self-Managed Metadata Quorum.

What are bootstrap servers Kafka?

bootstrap. servers is a comma-separated list of host and port pairs that are the addresses of the Kafka brokers in a "bootstrap" Kafka cluster that a Kafka client connects to initially to bootstrap itself. A host and port pair uses : as the separator.

What is the difference between Kafka and ZooKeeper?

In general, ZooKeeper provides an in-sync view of the Kafka cluster. Kafka, on the other hand, is dedicated to handling the actual connections from the clients (producers and consumers) as well as managing the topic logs, topic log partitions, consumer groups ,and individual offsets.


2 Answers

I have no idea what was wrong. Likely I put Kafka or Zookeeper in a weird state. After deleting the topics in the log.dir of each broker AND the zookeeper topics in /brokers/topics then recreating the topic, Kafka consumer behaved as expected.

like image 121
nico Avatar answered Oct 22 '22 08:10

nico


Bootstrap servers are same as kafka brokers. And if you want to see the list of bootstrap server zookeeper is providing, you can query ZNode information via any ZK client. All active brokers are registered under /brokers/ids/[brokerId]. All you need is zkQuorum address. Below command will give you list of active bootstrap servers :

./zookeeper-shell.sh localhost:2181 <<< "ls /brokers/ids"

like image 41
sam.ban Avatar answered Oct 22 '22 08:10

sam.ban