Kafka消费时报错:Producer connection to xxx:9092 unsuccessful

使用kafka消费数据时报Producer错误,具体错误如下:

kafka.producer.SyncProducer:103 Producer connection to xxx:9092 unsuccessful
java.nio.channels.ClosedByInterruptException
at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:202)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:659)
at kafka.network.BlockingChannel.connect(BlockingChannel.scala:57)
at kafka.producer.SyncProducer.connect(SyncProducer.scala:141)
at kafka.producer.SyncProducer.getOrMakeConnection(SyncProducer.scala:156)
at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(SyncProducer.scala:68)
at kafka.producer.SyncProducer.send(SyncProducer.scala:112)
at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:53)
at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:88)
at kafka.consumer.ConsumerFetcherManager$LeaderFinderThread.doWork(ConsumerFetcherManager.scala:66)
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:51)

xxx是kafka集群中的某一个节点主机名,虽然kafka消费者没有配置从此主机上取数据,但必须能够识别此主机名,因此在本机hosts文件里面修改(C:\Windows\System32\drivers\etc\hosts),增加域名映射:

192.168.0.120 xxx

问题解决。

posted @ 2018-11-12 19:29  codercg  阅读(1427)  评论(0编辑  收藏  举报