kafka无法网络访问问题

来源:互联网 发布:js java变量 编辑:程序博客网 时间:2024/05/25 16:39

refs:

http://stackoverflow.com/questions/17808988/using-kafka-java-producer-send-a-message-producer-connection-to-localhost9092

https://cwiki.apache.org/confluence/display/KAFKA/FAQ#FAQ-OnEC2%2Cwhycan%27tmyhighlevelconsumersconnecttothebrokers%3F


基于大部分实例都是用localhost在本机单例测试,想在网络上另一台机器访问,却怎么也连不上,经查阅发现是kafka的server.properties配置问题,默认是localhost,必须打开并用自己的ip地址。


server.properties.

host.name=192.168.1.203



Why can't my consumers/producers connect to the brokers?

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 metadata.broker.list 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 to be registered in ZK by setting the "hostname" property in server.properties. In another rare case where the binding host/port is different from the host/port for client connection, you can set advertised.host.name and advertised.port for client connection.


0 0
原创粉丝点击