Kafka java Client 错误 org.apache.kafka.clients.NetworkClient Error connecting to node 1 at slave2:909
最新推荐文章于 2022-12-31 17:15:32 发布
最新推荐文章于 2022-12-31 17:15:32 发布
阅读量
1.2w
[2017-09-09 13:34:40,648] [DEBUG] org.apache.kafka.clients.NetworkClient Initiating connection to node 1 at slave2:9092.
[2017-09-09 13:34:40,648] [DEBUG] org.apache.kafka.clients.NetworkClient Error connecting to node 1 at slave2:9092:
java.io.IOException: Can't resolve address: slave2:9092
at org.apache.kafka.common.network.Selector.connect(Selector.java:182)
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:629)
at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:186)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:184)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:139)
at java.lang.Thread.run(Unknown Source)
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Unknown Source)
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
at org.apache.kafka.common.network.Selector.connect(Selector.java:179)
... 5 more
解决方案:
在开发环境的hosts文件中添加解析
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
192.168.17.13 slave1
192.168.17.14 slave2
192.168.17.15 slave3
2020-08-19 22:55:56.089 WARN [-,,,] 35672 --- [ad | producer-1]
org
.
apache
.
kafka
.
client
s
.Net
work
Client
: [Producer
client
Id=producer-1]
Error
while fetching metadata with correlation id 483 : {abc_001=LEADER_NOT_AVAILABLE}
2020-08-19 22:55:56.205 WARN.
在使用Spring Cloud Bus(bus-
kafka
)做动态配置更新时,需要用到
Kafka
,启动报如下
错误
:
Connection
to
node
0 could not be establish
ed
. Broker may not be available.
Kafka
在Linux本机是连接正常的,后面排查得知,
Kafka
默认只能支持本机访问,要远程访问需修改配置
config/server.properties,取消如下两行注释,并把localhost改成访问本机的IP地址。
位置:
org
.
apache
.
kafka
.
client
s;
作用:用于异步请求/响应网络i/o的网络客户端。这是一个内部类,用于实现面向用户的生产者和消费者客户端,也就是说我们的生产请求和消费请求最后都会交给Net
work
Client
类处理。
在sender线程中run时调用去。用于发送请求
通过连接处理实际的读写操作............
无法解析
kafka
-0,这个名称是
kafka
的pod名称,由于
kafka
配置中没有设置advertis
ed
.listeners=参数导致,上面两个应用的报错都是由这一个原因导致的。● 修改
kafka
配置文件(由于第一次设置的是advertis
ed
.listeners=PLAINTEXT://localhost:
909
2,导致出现第二个
错误
问题)● 修改配置文件中的IP为实际IP地址,由于使用k8s容器化部署,IP不是固定的,这里配置为
kafka
的svc的域名即可。
2019-12-11 23:12:13.049 WARN 8604 --- [ntainer#0-0-C-1]
org
.
apache
.
kafka
.
client
s
.Net
work
Client
: [Consumer
client
Id=consumer-1, groupId=test-hello-group]
Error
connec
ting
to
node
test_host:
909
4 (id...
刚开始一直报错WARN [Consumer
client
Id=consumer-console-consumer-39725-1, groupId=console-consumer-39725] Bootstrap broker bd
node
01:
909
2 (id: -1 rack: null) dis
connec
t
ed
(
org
.
apache
.
kafka
.
client
s
.Net
work
Client
),第一天我没管,后来第二天启动时我把
java
编译的target删除了,这个
错误
没了(期间我换过spring版
Connection
to
node
0 could not be establish
ed
. Broker may not be available. (
org
.
apache
.
kafka
.
client
s
.Net
work
Client
)
Connection
to
node
1 (localhost/127.0.0.1:
909
2) could not be establish
ed
. Broker may not be available.
服务器已经开通了对应的端口,防火..