本文介绍了Kafka bootstrap-servers vs zookeeper in kafka-console-consumer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试测试运行具有 3 个代理的单个 Kafka 节点 &动物园管理员.我希望使用控制台工具进行测试.我这样运行生产者:

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

我可以在生产者中输入消息并在消费者中看到它们,正如预期的那样.然而,当我使用 bootstrap-server 运行更新版本的消费者时,我什么也得不到.例如

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

当我在端口 9092 上运行一个代理时,这运行良好,所以我非常困惑.有没有办法可以看到zookeeper提供的引导服务器?引导服务器与代理列表不同吗?Kafka 使用 Scala 2.11 编译.

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.

推荐答案

我不知道出了什么问题.可能我把 Kafka 或 Zookeeper 置于一种奇怪的状态.删除每个broker的log.dir中的topic和/brokers/topics中的zookeeper主题,然后重新创建topic后,Kafka消费者的行为符合预期.

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.

这篇关于Kafka bootstrap-servers vs zookeeper in kafka-console-consumer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 02:56