windows宿主机消费Linux虚拟机kafka集群报异常WARN Connection to node 0 could not be established. Broker may not be available
1、Linux
kafka_2.11-0.11.0.2 集群三台机子分别配置:
server.properties配置
advertised.listeners=PLAINTEXT://10.0.2.5:9092
advertised.listeners=PLAINTEXT://10.0.2.6:9092
advertised.listeners=PLAINTEXT://10.0.2.7:9092
2、Linux hosts配置
10.0.2.5 hadoop01.richstone.com
3、Linux nginx配置
stream {
upstream brokers {
server 10.0.2.5:9092 weight=1;
server 10.0.2.6:9092 weight=1;
server 10.0.2.7:9092 weight=1;
}
server {
listen 18001;
proxy_pass brokers;
}
}
4、虚拟机nat端口转发
10.0.2.5:18001 转发到宿主机127.0.0.1:18001
5、windows宿主机配置hosts配置
127.0.0.1 hadoop01.richstone.com
6、测试windows宿主机:
Telnet 127.0.0.1:18001 可以ping通
7、windows消费数据:
.\bin\windows\kafka-console-consumer.bat --topic first --bootstrap-server hadoop01.richstone.com:18001 --from-beginning
但是上面消费数据的时候报异常
WARN Connection to node 0 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)