Kafka Consumer客户端启动报错

最新搭建了一个kafka的集群,然后启动consumer(消费者)客户端的时候,报错如下:
ERROR [2017-02-11 06:23:12,708] kafka.producer.SyncProducer: Producer connection to kafkanode1:9092 unsuccessful
! java.nio.channels.UnresolvedAddressException: null
! at sun.nio.ch.Net.checkAddress(Net.java:127) ~[na:1.7.0_51]
! at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:644) ~[na:1.7.0_51]
! at kafka.network.BlockingChannel.connect(BlockingChannel.scala:57) ~[kafka-consumer.jar:na]
! at kafka.producer.SyncProducer.connect(SyncProducer.scala:141) [kafka-consumer.jar:na]
! at kafka.producer.SyncProducer.getOrMakeConnection(SyncProducer.scala:156) [kafka-consumer.jar:na]
! at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(SyncProducer.scala:68) [kafka-consumer.jar:na]
! at kafka.producer.SyncProducer.send(SyncProducer.scala:112) [kafka-consumer.jar:na]
! at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:53) [kafka-consumer.jar:na]
! at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:88) [kafka-consumer.jar:na]
! at kafka.consumer.ConsumerFetcherManager$LeaderFinderThread.doWork(ConsumerFetcherManager.scala:66) [kafka-consumer.jar:na]
这是是我没有解析主机名吗?
已邀请:

采菊篱下 - 无分享不快乐 助力技术开源分享 运维一枚

赞同来自:

consumer先会从zookeeper(/brokers/ids/1)获取到你可用kafka broker节点配置的host.name的值,你这里明显获取到的kafka broker节点信息host的值是kafkanode1,所以你只需要到你的consumer节点增加一条host记录就好:
echo "kafka_borker_ip kafkanode1" >> /etc/hosts

要回复问题请先登录注册