kafka JavaAPI遇到的坑

症状:Producer连不上,提示没有可用Node。

 

解决:在安装kafka的目录中配置server.properties

 

1、listeners=PLAINTEXT://:9092或listeners=PLAINTEXT://内网ip:9092  注:千万不能写localhost,否则虽然在本地可以通信,一旦外网通过JavaAPI访问就会出错。当然也不能写公网ip,否则报can‘t bind错误。

2、advertised.listeners=PLAINTEXT://公网ip:9092

3、hostname advertised.hostname不用配置。

 

另:server中关于socket listen的原注释:

# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.

默认配置应该是主机名,大概和内网ip等价,详细还需研究。

posted on 2018-08-15 10:27  kurama2018  阅读(881)  评论(0编辑  收藏  举报