向 kafka 发送消息的时候出现 LeaderNotAvailableException 异常?

2015-04-11 15:04:16 +08:00
 alangz

按照官网gettingStarted ->http://kafka.apache.org/documentation.html#gettingStarted ,我单独安装的zookeeper, 启动了三个boroker。创建了一个topic,按照官网的步骤发送消息的时候,总是出现LeaderNotAvailableException异常。

部分错误信息:

[2015-04-11 14:14:15,076] WARN Error while fetching metadata [{TopicMetadata for topic my-replicated-topic ->
No partition metadata for topic my-replicated-topic due to kafka.common.LeaderNotAvailableException}] for topic [my-replicated-topic]: class kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2015-04-11 14:14:15,076] ERROR Failed to collate messages by topic, partition due to: Failed to fetch topic metadata for topic: my-replicated-topic (kafka.producer.async.DefaultEventHandler)
[2015-04-11 14:14:15,183] WARN Error while fetching metadata [{TopicMetadata for topic my-replicated-topic ->
No partition metadata for topic my-replicated-topic due to kafka.common.LeaderNotAvailableException}] for topic [my-replicated-topic]: class kafka.common.LeaderNotAvailableException (kafka.producer.BrokerPartitionInfo)
[2015-04-11 14:14:15,186] ERROR Failed to send requests for topics my-replicated-topic with correlation ids in [0,8] (kafka.producer.async.DefaultEventHandler)
[2015-04-11 14:14:15,188] ERROR Error in handling batch of 1 events (kafka.producer.async.ProducerSendThread)
kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.
at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:90)
at kafka.producer.async.ProducerSendThread.tryToHandle(ProducerSendThread.scala:105)
at kafka.producer.async.ProducerSendThread$$anonfun$processEvents$3.apply(ProducerSendThread.scala:88)
at kafka.producer.async.ProducerSendThread$$anonfun$processEvents$3.apply(ProducerSendThread.scala:68)
at scala.collection.immutable.Stream.foreach(Stream.scala:594)
at kafka.producer.async.ProducerSendThread.processEvents(ProducerSendThread.scala:67)
at kafka.producer.async.ProducerSendThread.run(ProducerSendThread.scala:45)

在stackoverflow上面找到了一个类似的问题http://stackoverflow.com/questions/23228222/running-into-leadernotavailableexception-when-using-kafka-0-8-1-with-zookeeper-3 ,按照下面的回答说配置有问题,我停掉kafka和zookeeper清除掉kafka的log和zookeeper的内容。重新启动但还是有上述问题。

各位有遇到这个问题吗?

20504 次点击
所在节点    Kafka
5 条回复
lszwycn
2015-04-12 00:30:01 +08:00
你的topic是咋创建的?
alangz
2015-04-12 11:41:21 +08:00
@lszwycn 按照官网的教程:
```
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic my-replicated-topic
```
lszwycn
2015-04-12 22:04:00 +08:00
alangz
2015-04-13 13:59:17 +08:00
@lszwycn 改过了,按照他的文档一步一步做的
alangz
2015-05-15 14:49:39 +08:00
这个问题知道什么原因了,是因为主机名映射的ip错误,导致节点之间无法通信。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/183051

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX