V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
alangz
V2EX  ›  Kafka

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

  •  1
     
  •   alangz · 2015-04-11 15:04:16 +08:00 · 20509 次点击
    这是一个创建于 3517 天前的主题,其中的信息可能已经有所发展或是发生改变。

    按照官网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的内容。重新启动但还是有上述问题。

    各位有遇到这个问题吗?

    5 条回复    2015-05-15 14:49:39 +08:00
    lszwycn
        1
    lszwycn  
       2015-04-12 00:30:01 +08:00
    你的topic是咋创建的?
    alangz
        2
    alangz  
    OP
       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
        3
    lszwycn  
       2015-04-12 22:04:00 +08:00
    alangz
        4
    alangz  
    OP
       2015-04-13 13:59:17 +08:00
    @lszwycn 改过了,按照他的文档一步一步做的
    alangz
        5
    alangz  
    OP
       2015-05-15 14:49:39 +08:00
    这个问题知道什么原因了,是因为主机名映射的ip错误,导致节点之间无法通信。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5959 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 06:11 · PVG 14:11 · LAX 22:11 · JFK 01:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.