Kafka集群连接云服务节点-报通讯异常

错误如下:

java.io.IOException: Can't resolve address: ds105.usw2.location.io:19092
        at org.apache.kafka.common.network.Selector.doConnect(Selector.java:235) ~[kafka-clients-2.0.0.jar:na]
        at org.apache.kafka.common.network.Selector.connect(Selector.java:214) ~[kafka-clients-2.0.0.jar:na]
        at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:864) [kafka-clients-2.0.0.jar:na]
        at org.apache.kafka.clients.NetworkClient.access$700(NetworkClient.java:64) [kafka-clients-2.0.0.jar:na]
        at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1035) [kafka]
Caused by: java.nio.channels.UnresolvedAddressException: null

分析原因

Can't resolve address? 无法解析地址,首先排查,是否是集群问题?
1.首先使用jps查看kafka与zookeeper是否正常启动
[root@ppp_m_db base]# jps
24672 QuorumPeerMain
30656 Kafka
12482 Bootstrap //zookerper
16985 MycatStartup
36428 MycatStartup
27372 jar
5694 Jps
2.查看各个zookeeper的状态
[root@ppp_m_db bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /ppp/base/zookeeper/bin/../conf/zoo.cfg
Mode: follower
//能正常获取各个zookeeper节点的Mode类型,为Master或者follower,则接下来排除kafka
3.查看kafka的状态,多数为使用命令查看,如查看集群中各topics的状态
root@ppp_m_db bin]# ./kafka-topics.sh --describe --zookeeper 10.212.130.5:12181
Topic:I	PartitionCount:1	ReplicationFactor:2	Configs:
	Topic: I	Partition: 0	Leader: 2	Replicas: 2,0	Isr: 2,0
Topic:IF_LEAPSEC	PartitionCount:1	ReplicationFactor:2	Configs:
	Topic: IF_LEAPSEC	Partition: 0	Leader: 0	Replicas: 0,1	Isr: 0
//有结果则表明kafka集群运行正常
4.接下来查看是否是网络问题,根据后台报错,是无法解析主机名,那尝试在本地配置云服务kafka的IP+域名

配置Hosts中的IP与域名

1.文件目录是C:\Windows\System32\drivers\etc
在这里插入图片描述
在hosts文件中添加IP与域名

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost
0.0.0.0 account.jetbrains.com
35.163.126.244 ds99.usw2.location.io //云服务器kafka节点配置
52.25.155.233 ds105.usw2.location.io
52.27.244.78 ds106.usw2.location.io

重新编译或者运行项目,则发现错误已解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值