Kafka Uncaught error in kafka producer I/O thread: (org.apache.kafka.clients.producer.internals.Sender) java.lang.IllegalStateException: No entry found for connection 0

释放双眼,带上耳机,听听看~!
🤖 由 ChatGPT 生成的文章摘要

具体报错如下

[2023-08-29 06:25:19,540] ERROR [Producer clientId=console-producer] Uncaught error in kafka producer I/O thread:  (org.apache.kafka.clients.producer.internals.Sender)
java.lang.IllegalStateException: No entry found for connection 0
    at org.apache.kafka.clients.ClusterConnectionStates.nodeState(ClusterConnectionStates.java:339)
    at org.apache.kafka.clients.ClusterConnectionStates.disconnected(ClusterConnectionStates.java:143)
    at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:921)
    at org.apache.kafka.clients.NetworkClient.access$700(NetworkClient.java:67)
    at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1086)
    at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:971)
    at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:533)
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:311)
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:235)
    at java.lang.Thread.run(Thread.java:748)
[2023-08-29 06:25:19,554] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 18 : {one=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2023-08-29 06:25:19,655] ERROR [Producer clientId=console-producer] Uncaught error in kafka producer I/O thread:  (org.apache.kafka.clients.producer.internals.Sender)
java.lang.IllegalStateException: No entry found for connection 0
    at org.apache.kafka.clients.ClusterConnectionStates.nodeState(ClusterConnectionStates.java:339)
    at org.apache.kafka.clients.ClusterConnectionStates.disconnected(ClusterConnectionStates.java:143)
    at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:921)
    at org.apache.kafka.clients.NetworkClient.access$700(NetworkClient.java:67)
    at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1086)
    at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:971)
    at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:533)
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:311)
    at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:235)
    at java.lang.Thread.run(Thread.java:748)

解决办法:

问题原因:客户端在连接kafka集群时不能解析出kafka机器的hostname对应的ip值

在客户端的机器上添加kafka集群的Host。

原配置文件

root@abcdocker:~# cat /usr/local/kafka/config/server.properties
broker.id=1
listeners=PLAINTEXT://:9092
...

添加host解析

cat >>/etc/hosts<<EOF
192.168.31.70  kafka1   
192.168.31.71  kafka2   
192.168.31.72  kafka3   
EOF

修改后

[root@tmp-01 kafka]# cat config/server.properties
broker.id=0
listeners=PLAINTEXT://kafka1:9092

测试生产消费

  • 执行生产者命令
[root@tmp-01 kafka]#   /usr/local/kafka/bin/kafka-console-producer.sh --broker-list 192.168.31.70:9092 --topic one
>I am abcdocker
>site:i4t.com
>mail: 1272204@qq.com
>END!
  • 执行消费者命令
[root@tmp-01 kafka]#    /usr/local/kafka/bin/kafka-console-consumer.sh --bootstrap-server 192.168.31.70:9092 --from-beginning --topic one

I am abcdocker
site:i4t.com
END!

给TA打赏
共{{data.count}}人
人已打赏
Kafka

Kafka修改topic partition分区数

2023-8-22 16:30:27

Kafka

Kafka 安全认证SASL

2023-9-4 14:59:22

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索