kafka入门1-集群生产消息 报:ERROR Producer connection to localhost:9092 unsuccessful

./kafka-console-producer.sh --broker-list localhost:9092 --topic topic1,报下面的错

[2014-12-02 14:16:21,565] ERROR Producer connection to localhost:9092 unsuccessful (kafka.producer.SyncProducer)
java.net.ConnectException: Connection refused
        at sun.nio.ch.Net.connect0(Native Method)
        at sun.nio.ch.Net.connect(Net.java:465)
        at sun.nio.ch.Net.connect(Net.java:457)
        at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:670)
        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)atkafka.producer.SyncProducer.send(SyncProducer.scala:112)atkafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:53)atkafka.producer.BrokerPartitionInfo.updateInfo(BrokerPartitionInfo.scala:82)atkafka.producer.async.DefaultEventHandler
anonfun$handle$1.apply$mcV$sp(DefaultEventHandler.scala:67)
        at kafka.utils.Utils$.swallow(Utils.scala:167)
        at kafka.utils.Logging$class.swallowError(Logging.scala:106)
        at kafka.utils.Utils$.swallowError(Utils.scala:46)
        at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:67)
        at kafka.producer.async.ProducerSendThread.tryToHandle(ProducerSendThread.scala:104)
        at kafka.producer.async.ProducerSendThread
anonfun$processEvents$3.apply(ProducerSendThread.scala:87)atkafka.producer.async.ProducerSendThread
anonfun$processEvents$3.apply(ProducerSendThread.scala:67)
        at scala.collection.immutable.Stream.foreach(Stream.scala:526)
        at kafka.producer.async.ProducerSendThread.processEvents(ProducerSendThread.scala:66)
        at kafka.producer.async.ProducerSendThread.run(ProducerSendThread.scala:44)
[2014-12-02 14:16:21,572] WARN Fetching topic metadata with correlation id 0 for topics [Set(topic1)] from broker [id:0,host:localhost,port:9092] failed (kafka.client.ClientUtils$)
java.net.ConnectException: Connection refused
        at sun.nio.ch.Net.connect0(Native Method)
        at sun.nio.ch.Net.connect(Net.java:465)
        at sun.nio.ch.Net.connect(Net.java:457)
        at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:670)
        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)atkafka.producer.SyncProducer.send(SyncProducer.scala:112)atkafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:53)atkafka.producer.BrokerPartitionInfo.updateInfo(BrokerPartitionInfo.scala:82)atkafka.producer.async.DefaultEventHandler
anonfun$handle$1.apply$mcV$sp(DefaultEventHandler.scala:67)
        at kafka.utils.Utils$.swallow(Utils.scala:167)
        at kafka.utils.Logging$class.swallowError(Logging.scala:106)
        at kafka.utils.Utils$.swallowError(Utils.scala:46)
        at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:67)
        at kafka.producer.async.ProducerSendThread.tryToHandle(ProducerSendThread.scala:104)
        at kafka.producer.async.ProducerSendThread
anonfun$processEvents$3.apply(ProducerSendThread.scala:87)atkafka.producer.async.ProducerSendThread
anonfun$processEvents$3.apply(ProducerSendThread.scala:67)
        at scala.collection.immutable.Stream.foreach(Stream.scala:526)
        at kafka.producer.async.ProducerSendThread.processEvents(ProducerSendThread.scala:66)
        at kafka.producer.async.ProducerSendThread.run(ProducerSendThread.scala:44)
[2014-12-02 14:16:21,575] ERROR fetching topic metadata for topics [Set(topic1)] from broker [ArrayBuffer(id:0,host:localhost,port:9092)] failed (kafka.utils.Utils$)
kafka.common.KafkaException: fetching topic metadata for topics [Set(topic1)] from broker [ArrayBuffer(id:0,host:localhost,port:9092)] failed


原因:是在集群环境里执行了单机的命令

解决方法:

1)vi producer.properties

#metadata.broker.list=localhost:9092
metadata.broker.list=192.168.11.222:9092,192.168.11.221:9092,192.168.11.220:9092

2)./kafka-console-producer.sh --broker-list IP1:9092,IP2:9092,IP3:9092 --topic topic1

阅读更多
文章标签: kafka
个人分类: kafka
上一篇45 个非常有用的 Oracle 查询语句
下一篇Hbase出现ERROR: Can't get master address from ZooKeeper; znode data == null解决办法
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭