Kafka:如何连接 kafka-console-consumer 以获取远程代理主题内容? [英] Kafka : How to connect kafka-console-consumer to fetch remote broker topic content?
问题描述
我在 ec2 上的一台机器上设置了一个 kafka zookeeper 和 3 个代理,端口为 9092..9094,我正在尝试使用另一台机器上的主题内容.端口 2181 (zk)、9092、9093 和 9094(服务器)对消费者机器开放.我什至可以做一个 bin/kafka-topics.sh --describe --zookeeper 172.X.X.X:2181 --topic remotetopic
这给了我
Topic:remotetopic PartitionCount:1 ReplicationFactor:3 配置:主题:remotetopic 分区:0 领导者:2 副本:2,0,1 Isr:2,0,1块引用
但是当我执行 bin/kafka-console-consumer.sh --zookeeper 172.X.X.X:2181 --from-beginning --topic remotetopic
我得到 p><块引用>
警告从代理 [id:0,host:localhost,port:9092] 获取主题 [Set(remotetopic)] 的关联 ID 为 0 的主题元数据失败 (kafka.client.ClientUtils$)java.nio.channels.ClosedChannelException
为什么消费者试图从本地主机读取?是否有任何选项或命令行或默认文件从中读取;我可以改变吗?
任何帮助将不胜感激!
我遇到了同样的问题,我正在使用 kafka 0.11 并且我在我的 Ubuntu VM 和 Windows 10 中启动了生产者和代理.
我已更改(且未注释)
advertised.listeners=PLAINTEXT://your.host.name:9092
到
advertised.listeners=PLAINTEXT://:9092
示例:
advertised.listeners=PLAINTEXT://192.168.150.150:9092
来自服务器/代理端的文件 config/server.properties(即在我的情况下它是 Ubuntu VM)
I have setup a kafka zookeeper and 3 brokers on one machine on ec2 with ports 9092..9094 and am trying to consume the topic content from another machine. The ports 2181 (zk), 9092, 9093 and 9094 (servers) are open to the consumer machine. I can even do a bin/kafka-topics.sh --describe --zookeeper 172.X.X.X:2181 --topic remotetopic
which gives me
Topic:remotetopic PartitionCount:1 ReplicationFactor:3 Configs: Topic: remotetopic Partition: 0 Leader: 2 Replicas: 2,0,1 Isr: 2,0,1 Blockquote
However when i do bin/kafka-console-consumer.sh --zookeeper 172.X.X.X:2181 --from-beginning --topic remotetopic
I get
WARN Fetching topic metadata with correlation id 0 for topics [Set(remotetopic)] from broker [id:0,host:localhost,port:9092] failed (kafka.client.ClientUtils$) java.nio.channels.ClosedChannelException
Why is the consumer trying to read from localhost? Is there any option or commandline or default file where this is read from; and I can change it?
Any help would be appreciated!
I had same problem , I am using kafka 0.11 and I started producer and broker in my Ubuntu VM and consumer in Windows 10.
I had changed (and uncommented)
advertised.listeners=PLAINTEXT://your.host.name:9092
to
advertised.listeners=PLAINTEXT://<myActual IP address>:9092
example:
advertised.listeners=PLAINTEXT://192.168.150.150:9092
from file config/server.properties at server/broker side (i.e. in my case it was Ubuntu VM)
这篇关于Kafka:如何连接 kafka-console-consumer 以获取远程代理主题内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!