1
Python kafka不起作用。任何理由?我的意思是我不能連接到kafka,我得到一個錯誤?是否有一個與0.8一起工作的kafka客戶端?我的意思是這是一個全新的服務器。我剛啓動它。
我使用https://github.com/mumrah/kafka-pythonpython和kafka KeyError:-1
from kafka.client import KafkaClient
kafka = KafkaClient(kafka_domain, 9092)
Traceback (most recent call last):
File "/home/ubuntu/workspace/rtbhui-devops/simulations/pixel_druid_simulations.py", line 36, in <module>
kafka = KafkaClient(kafka_domain, 9092)
File "/usr/local/lib/python2.7/dist-packages/kafka/client.py", line 38, in __init__
self.load_metadata_for_topics() # bootstrap with all metadata
File "/usr/local/lib/python2.7/dist-packages/kafka/client.py", line 247, in load_metadata_for_topics
self.topics_to_brokers[topic_part] = brokers[meta.leader]
KeyError: -1
卡夫卡的日誌我看到了下面。
[2014-02-26 08:36:21,471] INFO Closing socket connection to /222.127.xxx.xxx. (kafka.network.Processor)
[2014-02-26 08:40:30,801] ERROR [KafkaApi-1393401480] Error while fetching metadata for partition [topic-pixel,0] (kafka.server.KafkaApis)
kafka.common.LeaderNotAvailableException: Leader not available for partition [topic-pixel,0]
at kafka.server.KafkaApis$$anonfun$17$$anonfun$20.apply(KafkaApis.scala:474)
at kafka.server.KafkaApis$$anonfun$17$$anonfun$20.apply(KafkaApis.scala:462)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:206)
at scala.collection.immutable.List.map(List.scala:45)
at kafka.server.KafkaApis$$anonfun$17.apply(KafkaApis.scala:462)
at kafka.server.KafkaApis$$anonfun$17.apply(KafkaApis.scala:458)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.immutable.Set$Set1.foreach(Set.scala:81)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:206)
at scala.collection.immutable.Set$Set1.map(Set.scala:68)
at kafka.server.KafkaApis.handleTopicMetadataRequest(KafkaApis.scala:458)
at kafka.server.KafkaApis.handle(KafkaApis.scala:68)
at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:42)
at java.lang.Thread.run(Thread.java:744)
我也是!你有沒有刪除一個主題?當我使用kafka命令行工具刪除所有主題時,我看到了這一點。 – RickyA
我認爲這發生在[領導人選舉沒有正確執行]時(http://grokbase.com/t/kafka/users/13b7rqp3dj/leader-no-available-for-partiton-error)。當'kafka-topics.sh --describe'說領導是'1'時,我有錯誤,當它再次變成'0'時它就消失了。 – RickyA