问题描述
昨天我成功设置了zookeeper和一个kafka broker.一切都按预期进行.我关闭了 kafka (ctrl + c),然后关闭了 zookeeper.
I was able to successfully set up zookeeper and one kafka broker yesterday. Everything worked as expected. I shut down kafka (ctrl + c) and then zookeeper.
今天我启动了 zookeeper,当我启动 kafka (bin/kafka-server-start.sh config/server0.properties
) 时,出现以下错误.我尝试了各种建议的补救措施(完全删除我的 kafka 安装并从头开始重新安装).我仍然遇到同样的错误.
Today I started zookeeper and when I started kafka (bin/kafka-server-start.sh config/server0.properties
), I get the following error. I tried various remedies suggested (removing completely my kafka installation and doing it again from scratch). Still I get same error.
[2016-09-28 16:15:55,895] FATAL Fatal error during KafkaServerStartable startup. Prepare to shutdown (kafka.server.KafkaServerStartable)
java.lang.RuntimeException: A broker is already registered on the path /brokers/ids/0. This probably indicates that you either have configured a brokerid that is already in use, or else you have shutdown this broker and restarted it faster than the zookeeper timeout so it appears to be re-registering.
at kafka.utils.ZkUtils.registerBrokerInZk(ZkUtils.scala:305)
at kafka.utils.ZkUtils.registerBrokerInZk(ZkUtils.scala:291)
at kafka.server.KafkaHealthcheck.register(KafkaHealthcheck.scala:70)
at kafka.server.KafkaHealthcheck.startup(KafkaHealthcheck.scala:51)
at kafka.server.KafkaServer.startup(KafkaServer.scala:244)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:37)
at kafka.Kafka$.main(Kafka.scala:67)
at kafka.Kafka.main(Kafka.scala)
[2016-09-28 16:15:55,896] INFO [Kafka Server 0], shutting down (kafka.server.KafkaServer)
全部在mac中设置
推荐答案
我在设置 kafka 和 zookeeper 多节点集群时遇到了同样的问题.
I have faced the same issue while setting up the kafka and zookeeper multinode cluster.
根本原因:
由于zookeeper ensemble需要一些时间来设置,所以当我们启动kafka brokers时,所有zookeeper节点可能还没有加入zookeeper ensemble.
As zookeeper ensemble takes some time to setup so when we start kafka brokers, all zookeeper nodes might have not joined zookeeper ensemble yet.
所以可能是一个 kafka 节点连接到一个尚未加入集合的 zookeeper 节点.
So It may be the case that one kafka node connected to a zookeeper node which is not yet in the ensemble.
另一个原因可能是 kafka broker 被杀死而不是停止.当你杀死你的 kafka 进程或者它崩溃并且它没有正确关闭它的 zookeeper 连接时.
Another reason can be kafka broker is killed instead of stopped.When you kill your kafka process or it crashes and it does not close its zookeeper connection correctly.
解决方案:
为避免这种情况,请确保在启动 kafka broker 之前您的 zookeeper 集合已启动并正在运行.
To avoid this situation make sure your zookeeper ensemble is up and running before starting kafka brokers.
在 zookeeper 和 kafka 代理服务启动和停止之间添加适当的等待.
Add proper waits between zookeeper and kafka broker services start and stop.
这篇关于启动 kafka 代理时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!