1. 连接kafka时报错:Connection to xxx could not be established. Broker may not be available.
在配置文件config/server.properties中,确认listeners和advertised.listeners的配置。
listeners=PLAINTEXT://kafka-host:9092
advertised.listeners=PLAINTEXT://kafka-host:9092
在访问kafka的机器上,应在hosts文件中添加对应主机名的映射。
windows系统的主机映射文件为:C:\Windows\System32\drivers\etc\hosts
Linux系统的主机映射文件为:/etc/hosts
192.168.0.181 kafka-host
2. 由于配置修改为主机名的形式导致metricbeat.exe监控时出现错误
采用ip地址连接时,错误信息:
No advertised broker with address xx.xx.xx.xx:9092 found
修改为与配置一致的主机名方式,正常上传监控数据。
hosts: ["192.168.0.181:9092"]
修改为:
hosts: ["kafka-host:9092"]
但是使用kafka控制台客户端是可以通过ip地址进行连接的。