无法建立到节点 -1 的连接。经纪人可能不可用。 (org.apache.kafka.clients.NetworkClient)
Posted
技术标签:
【中文标题】无法建立到节点 -1 的连接。经纪人可能不可用。 (org.apache.kafka.clients.NetworkClient)【英文标题】:Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient) 【发布时间】:2019-10-03 07:21:07 【问题描述】:我已经安装了 Kafka 并进行了一些基本测试。我可以使用 Kafka-broker/bin 文件夹下提供的脚本创建主题。
但是当我每次运行它时都试图产生低于 WARNing 的消息时。并且不会生成任何消息。请指教。
[root@node2 bin]# ./kafka-console-producer.sh --broker-list localhost:9092 --topic test_master
>testmsg1
[2019-05-15 06:25:19,092] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2019-05-15 06:25:19,197] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2019-05-15 06:25:19,349] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2019-05-15 06:25:19,562] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2019-05-15 06:25:20,017] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2019-05-15 06:25:20,876] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2019-05-15 06:25:21,987] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2019-05-15 06:25:22,957] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2019-05-15 06:25:23,818] WARN [Producer clientId=console-producer] Connection to node -1 could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
^Corg.apache.kafka.common.KafkaException: Producer closed while send in progress
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:826)
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:803)
at kafka.tools.ConsoleProducer$.send(ConsoleProducer.scala:75)
at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:57)
at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)
Caused by: org.apache.kafka.common.KafkaException: Requested metadata update after close
at org.apache.kafka.clients.Metadata.awaitUpdate(Metadata.java:188)
at org.apache.kafka.clients.producer.KafkaProducer.waitOnMetadata(KafkaProducer.java:938)
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:823)
... 4 more
【问题讨论】:
【参考方案1】:打开集群中每个代理的Server.xml
并进行以下更改
将listeners=PLAINTEXT://:9092
更改为listeners=PLAINTEXT://<our ip address>:9092
【讨论】:
【参考方案2】:只需删除您的本地主机并写入端口
示例:
--broker-list 172.0.0.1:9092 将更改为 --broker-list :9092
【讨论】:
以上是关于无法建立到节点 -1 的连接。经纪人可能不可用。 (org.apache.kafka.clients.NetworkClient)的主要内容,如果未能解决你的问题,请参考以下文章