为什么我无法从外部连接到Kafka? [英] Why I cannot connect to Kafka from outside?

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

问题描述

我在ec2实例上运行kafka。因此,亚马逊ec2实例具有两个ip,一个是内部ip,第二个是供外部使用。

I am running kafka on ec2 instance. So amazon ec2 instance has two ips one is internal ip and second one is for external use.

我从本地计算机创建了生产者,但是它重定向到内部ip并给我连接失败的错误。谁能帮助我在ec2实例上配置kafka,以便我可以从本地计算机运行生产者。我尝试了多种组合,但没有用。

I created producer from local machine, but it redirect to internal ip and give me connection unsuccessful error. Can anybody help me to configure kafka on ec2 instance, so that I can run producer from local machine. I am tried many combinations but didn't work.

推荐答案

卡夫卡常见问题解答(已针对新属性进行更新),您可以阅读:

In the Kafka FAQ (updated for new properties) you can read:


当经纪人启动时,它在ZK中注册其ip /端口。您需要确保注册的IP与生产者配置中 bootstrap.servers 中列出的IP一致。默认情况下,注册的IP由 InetAddress.getLocalHost.getHostAddress()给出。通常,这应该返回主机的真实IP。但是,有时(例如,在EC2中),返回的ip是内部ip,无法从外部连接到ip。解决方案是通过在 server.properties advertised.listeners 属性来显式设置要在ZK中注册的主机ip和端口。 $ c>。

When a broker starts up, it registers its ip/port in ZK. You need to make sure the registered ip is consistent with what's listed in bootstrap.servers in the producer config. By default, the registered ip is given by InetAddress.getLocalHost.getHostAddress(). Typically, this should return the real ip of the host. However, sometimes (e.g., in EC2), the returned ip is an internal one and can't be connected to from outside. The solution is to explicitly set the host ip and port to be registered in ZK by setting the advertised.listeners property in server.properties.

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

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