开发环境:win10+Eclipse
服务器:centos+kafka0.10.2
错误:
[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