关闭

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

标签: kafka
4013人阅读 评论(0) 收藏 举报
分类:

./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

1
1

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:123690次
    • 积分:1161
    • 等级:
    • 排名:千里之外
    • 原创:14篇
    • 转载:69篇
    • 译文:0篇
    • 评论:6条
    文章分类
    最新评论