我在NodeJS中有一个kafka应用程序。我在我的本地机器上运行该应用程序,这绝对没问题。我在生产服务器上设置了相同的应用程序。我使用init.d启动了Kafka和zookeeper。 3天后,卡夫卡给了我一个例外'LeaderNotFound'。我试图在我的本地机器上重新生成此错误,我发现当我删除/ tmp / kafka-logs / broker0时会发生此错误。我在Kafka中的主题与主题“印象”的配置相同:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic impression
我通过更改服务器在本地系统上解决了这个问题,我的意思是我创建了另一个名为server-1.properties的代理并运行它。之后一切都很好,但我不认为这是正确的解决方案。你能指导我如何摆脱这个问题。
我得到的例外是:
[grunt-develop] > Events are sending to Kafka producer......
[grunt-develop] > Events are consumed by Kafka consumer......
[grunt-develop] > EventType in Consumer:click
[grunt-develop] > Incrementing sdk-server.apps.5637.requests.click
[grunt-develop] > Incrementing sdk-server.servers.ubuntu.requests.click
[grunt-develop] > POST /api/track/clk 200 116.987 ms - 68
[grunt-develop] > [ 'LeaderNotAvailable' ]
[grunt-develop] > Sent Event:click to Kafka!
[grunt-develop] > undefined
[grunt-develop] > events.js:74
[grunt-develop] > throw TypeError('Uncaught, unspecified "error" event.');
[grunt-develop] > ^
[grunt-develop] > TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>)
at emit (events.js:74:15)
at /home/asif/node_modules/kafka-node/lib/consumer.js:120:29
at null.<anonymous> (/home/asif/node_modules/kafka-node/lib/client.js:387:24)
at Client.handleReceivedData (/home/asif/node_modules/kafka-node/lib/client.js:563:18)
at Socket.<anonymous> (/home/asif/node_modules/kafka-node/lib/client.js:534:14)
at Socket.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:765:14)
at Socket.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:427:10)
>> application exited with code 8
当我尝试使用Producer控制台时,结果如下:(主题是“点击”与展示相同的配置)
/kafka_2.11-0.8.2.1$ bin/kafka-console-producer.sh --broker-list localhost:92 --topic click
[2015-09-02 09:05:54,379] WARN Property topic is not valid (kafka.utils.VerifiableProperties)
hello from click
[2015-09-02 09:06:03,733] WARN Error while fetching metadata partition 0 leader: none replicas: isr: isUnderReplicated: false for topic partition [click,0]: [class kafka.common.LeaderNotAvailableException] (kafka.producer.BrokerPartitionInfo)
[2015-09-02 09:06:03,763] WARN Failed to collate messages by topic,partition due to: No leader for any partition in topic click (kafka.producer.async.DefaultEventHandler)
[2015-09-02 09:06:03,876] WARN Error while fetching metadata partition 0 leader: none replicas: isr: isUnderReplicated: false for topic partition [click,0]: [class kafka.common.LeaderNotAvailableException] (kafka.producer.BrokerPartitionInfo)
[2015-09-02 09:06:03,878] WARN Failed to collate messages by topic,partition due to: No leader for any partition in topic click (kafka.producer.async.DefaultEventHandler)
[2015-09-02 09:06:03,983] WARN Error while fetching metadata partition 0 leader: none replicas: isr: isUnderReplicated: false for topic partition [click,0]: [class kafka.common.LeaderNotAvailableException] (kafka.producer.BrokerPartitionInfo)
[2015-09-02 09:06:03,985] WARN Failed to collate messages by topic,partition due to: No leader for any partition in topic click (kafka.producer.async.DefaultEventHandler)
[2015-09-02 09:06:04,091] WARN Error while fetching metadata partition 0 leader: none replicas: isr: isUnderReplicated: false for topic partition [click,0]: [class kafka.common.LeaderNotAvailableException] (kafka.producer.BrokerPartitionInfo)
[2015-09-02 09:06:04,094] WARN Failed to collate messages by topic,partition due to: No leader for any partition in topic click (kafka.producer.async.DefaultEventHandler)
[2015-09-02 09:06:04,201] WARN Error while fetching metadata partition 0 leader: none replicas: isr: isUnderReplicated: false for topic partition [click,0]: [class kafka.common.LeaderNotAvailableException] (kafka.producer.BrokerPartitionInfo)
[2015-09-02 09:06:04,206] ERROR Failed to send requests for topics click with correlation ids in [0,8] (kafka.producer.async.DefaultEventHandler)
[2015-09-02 09:06:04,208] 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)
答案 0 :(得分:0)
根据我的理解,你传递的是
的错误值- broker-list localhost:92
请提供有效的 PORT 和 HOSTNAME ,它应该有效。