Kafka 报错分析

1.Producer connection to localhost:9092 unsuccessful

远程连接kafka发送消息成功的话是这样:

15-12-02 17:46:57,581 INFO  kafka.producer.SyncProducer(?:?) ## Connected to 172.16.4.214:9092 for producing

经常报错如下:

015-12-02 15:14:12  [ pool-1-thread-2:4217697 ] - [ ERROR ]  Failed to collatemessages by topic, partition due to: fetching topic metadata for topics [Set(test)] from broker [ArrayBuffer(id:0,host:172.16.4.214,port:9092)] failed
2015-12-02 15:14:12  [ pool-1-thread-5:4217707 ] - [ ERROR ]  Producer connection to 172.16.4.214:9092 unsuccessful
java.net.ConnectException: Connection refused: connect
	at sun.nio.ch.Net.connect0(Native Method)
	at sun.nio.ch.Net.connect(Net.java:435)
	at sun.nio.ch.Net.connect(Net.java:427)
	at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:643)
	at kafka.network.BlockingChannel.connect(Unknown Source)
	at kafka.producer.SyncProducer.connect(Unknown Source)
	at kafka.producer.SyncProducer.getOrMakeConnection(Unknown Source)
	at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(Unknown Source)
	at kafka.producer.SyncProducer.send(Unknown Source)
	at kafka.client.ClientUtils$.fetchTopicMetadata(Unknown Source)
	at kafka.producer.BrokerPartitionInfo.updateInfo(Unknown Source)
	at kafka.producer.async.DefaultEventHandler$$anonfun$handle$2.apply$mcV$sp(Unknown Source)
	at kafka.utils.Utils$.swallow(Unknown Source)
	at kafka.utils.Logging$class.swallowError(Unknown Source)
	at kafka.utils.Utils$.swallowError(Unknown Source)
	at kafka.producer.async.DefaultEventHandler.handle(Unknown Source)
	at kafka.producer.Producer.send(Unknown Source)
	at kafka.javaapi.producer.Producer.send(Unknown Source)
	at com.hta.webmagic.pipeline.TestKafkaPipeline.KafkaProducer(TestKafkaPipeline.java:42)
	at com.hta.webmagic.pipeline.TestKafkaPipeline.process(TestKafkaPipeline.java:35)
	at us.codecraft.webmagic.Spider.processRequest(Spider.java:439)
	at us.codecraft.webmagic.Spider$1.run(Spider.java:336)
	at us.codecraft.webmagic.thread.CountableThreadPool$1.run(CountableThreadPool.java:74)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
2015-12-02 15:14:12  [ pool-1-thread-5:4217707 ] - [ ERROR ]  fetching topic metadata for topics [Set(test)] from broker [ArrayBuffer(id:0,host:172.16.4.214,port:9092)] failed
kafka.common.KafkaException: fetching topic metadata for topics [Set(test)] from broker [ArrayBuffer(id:0,host:172.16.4.214,port:9092)] failed
	at kafka.client.ClientUtils$.fetchTopicMetadata(Unknown Source)
	at kafka.producer.BrokerPartitionInfo.updateInfo(Unknown Source)
	at kafka.producer.async.DefaultEventHandler$$anonfun$handle$2.apply$mcV$sp(Unknown Source)
	at kafka.utils.Utils$.swallow(Unknown Source)
	at kafka.utils.Logging$class.swallowError(Unknown Source)
	at kafka.utils.Utils$.swallowError(Unknown Source)
	at kafka.producer.async.DefaultEventHandler.handle(Unknown Source)
	at kafka.producer.Producer.send(Unknown Source)
	at kafka.javaapi.producer.Producer.send(Unknown Source)
	at com.hta.webmagic.pipeline.TestKafkaPipeline.KafkaProducer(TestKafkaPipeline.java:42)
	at com.hta.webmagic.pipeline.TestKafkaPipeline.process(TestKafkaPipeline.java:35)
	at us.codecraft.webmagic.Spider.processRequest(Spider.java:439)
	at us.codecraft.webmagic.Spider$1.run(Spider.java:336)
	at us.codecraft.webmagic.thread.CountableThreadPool$1.run(CountableThreadPool.java:74)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection refused: connect
	at sun.nio.ch.Net.connect0(Native Method)
	at sun.nio.ch.Net.connect(Net.java:435)
	at sun.nio.ch.Net.connect(Net.java:427)
	at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:643)
	at kafka.network.BlockingChannel.connect(Unknown Source)
	at kafka.producer.SyncProducer.connect(Unknown Source)
	at kafka.producer.SyncProducer.getOrMakeConnection(Unknown Source)
	at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(Unknown Source)
	at kafka.producer.SyncProducer.send(Unknown Source)
	... 17 more



问题分析:


kafka 版本检查
kafka_2.10-0.8.2.2
基本上就是server.xml 配置问题,保证hostname 和zookeer 的IP地址正确


版本:kafka_2.10-0.9.0.0
最后报错最可能是hosts 文件配置问题,需要配置好对应关系
这点和clouder 的集群安装类似
然后再检查server.xml 配置文件


报错表现:
本地命令行可以正常的发送、接收消息,Eclipse 和远程机器无法发送消息。   

你可能感兴趣的:(kafka)