问题从外部连接kafka [英] Issue in connecting kafka from outside

查看:218
本文介绍了问题从外部连接kafka的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用hortonwork Sandbox for kafka服务器
尝试从eclipse与java代码连接kafka。
使用此配置连接到生产者发送消息

  metadata.broker.list = sandbox.hortonworks.com :45000 
serializer.class = kafka.serializer.DefaultEncoder
zk.connect = sandbox.hortonworks.com:2181
request.required.acks = 0
producer.type = sync

其中,sandbox.hortonworks.com是我连接到的sandboxname



in kafka server.properties我改变了这个配置

  host.name = sandbox.hortonworks.com 

advertised.host.name =系统IP(我的eclipse正在运行)
advertised.port = 45000

也做了端口转发,

我可以通过eclipse连接到kafka服务器,但是在发送消息的时候得到异常
异常尝试3次后无法发送消息。

解决方案

首先确保您已配置仅主机网络你的Hortonworks S andbox VM,如下所述:



http://hortonworks.com/community/forums/topic/use-host-only-networking-for-the-virtual-machine/



完成此操作后,您的沙箱虚拟机应该会得到一个IP(例如192.168.56.101),它应该可以从您的主机通过SSH,如

  $ ssh root@192.168.56.101 

然后在 http://192.168.56.101:8080/ 并将Kafka配置更改为

  listeners = PLAINTEXT:/ /0.0.0.0:6667 
advertised.listeners = PLAINTEXT://192.168.56.101:6667

必须在Custom kafka-broker一节中添加后一个属性(另见 http://hortonworks.com/community/forums/topic/ambari-alerts-how-to-change-kafka-port/ )。

然后通过Ambari启动/重新启动Kafka。您现在应该可以从Hortonworks Sandbox VM之外访问Kafka。您可以使用例如(从沙盒虚拟机外部)对此进行测试。来自Kafka发行版的Kafka控制台制作者,如

  $ bin / kafka-topics.sh --create --zookeeper localhost:2181 - 复制因子1  - 分部1  - 主题测试
$ bin / kafka-console-producer.sh - 主题测试 - 经纪人列表192.168.56.101:6667


I am using hortonwork Sandbox for kafka server trying to connect kafka from eclipse with java code . Use this configuration to connect to producer to send the message

metadata.broker.list=sandbox.hortonworks.com:45000
serializer.class=kafka.serializer.DefaultEncoder
zk.connect=sandbox.hortonworks.com:2181
request.required.acks=0
producer.type=sync

where sandbox.hortonworks.com is sandboxname to whom i connect

in kafka server.properties I changed this configuration

host.name=sandbox.hortonworks.com

advertised.host.name=System IP(on which my eclipse is running)
advertised.port=45000

did the port forwarding also ,

I am able to connect to kafka server from eclipse but while sending the message get the exception Exception"Failed to send messages after 3 tries."

解决方案

First make sure you have configured host-only network for your Hortonworks Sandbox VM as described here:

http://hortonworks.com/community/forums/topic/use-host-only-networking-for-the-virtual-machine/

After doing this your sandbox VM should get a IP (e.g. 192.168.56.101) and it should be reachable from your host via SSH like

$ ssh root@192.168.56.101

Then open Ambari at http://192.168.56.101:8080/ and change the Kafka configuration to

listeners=PLAINTEXT://0.0.0.0:6667
advertised.listeners=PLAINTEXT://192.168.56.101:6667 

The latter property must be added in the section "Custom kafka-broker" (See also http://hortonworks.com/community/forums/topic/ambari-alerts-how-to-change-kafka-port/).

Then start/restart Kafka via Ambari. You should now be able to access Kafka from outside the Hortonworks Sandbox VM. You can test this (from outside of the sandbox VM) using e.g. the Kafka console producer from the Kafka distribution like

$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
$ bin/kafka-console-producer.sh --topic test --broker-list 192.168.56.101:6667

这篇关于问题从外部连接kafka的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆