Kafka集群和客户端不在同一个网段报错 -Batch containing 11 record(s) expired due to timeout while requesting metadata

背景:
Kafka集群在一个192.168.0.x网段的,而我们的生产者在192.168.17.x网段的一台机器上,故当生产者发送消息给Kafka时,
无法将消息发送过去。

错误:
11:21:13,936 ERROR KafkaProducer - Batch containing 11 record(s) expired due to timeout while requesting metadata from brokers for onlinelogs-1

分析:
1.做Kafka集群的demo测试是OK的,详情参考:http://blog.itpub.net/30089851/viewspace-2132049/

2.在生产者机器上 telnet kafka节点ip 9092 ,也是通的,甚是奇怪。

3.谷歌了几下:
需要配置 advertised.host.name 参数,将Kafka各个节点,该参数配置为当前机器的IP即可,重启生效配置,测试OK。

新版本的参数:advertised.listeners

Author: Tunan
Link: http://yerias.github.io/2018/10/12/PE/4/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.