1. 程式人生 > >WARN [Consumer clientId=consumer-1, groupId=console-consumer-94437] Connection to node -1

WARN [Consumer clientId=consumer-1, groupId=console-consumer-94437] Connection to node -1

 

目前發現報錯的原因有三個,主機localhost出錯,端口出錯,防火牆沒關

 

1.顯示的是連線localhost/172.0.0.1出錯。

WARN [Consumer clientId=consumer-1, groupId=console-consumer-94437] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

將localhost換成自己主機的ip地址。

2.端口出錯,例如:localhost/172.16.194.28:2181,將埠2181改為9092。

WARN [Consumer clientId=consumer-1, groupId=console-consumer-17082] Connection to node -1 (server08/172.16.194.28:2181) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)

原因:

老版本使用的(consumer)消費資料命令:

kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

在新版本中--zookeeper已經被--bootstrap-server代替,埠也由之前的zookeeper通訊埠2181,改為了kafka通訊埠9092.

 

3.防火牆沒關

檢視防火牆狀態

firewall-cmd --state

關閉防火牆

systemctl stop firewalld.service

啟動消費(consumer)程序

kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning