kafka 启动报错

虚拟机上的 kafka 被强制断电之后,重新启动的时候报错

[2019-01-03 15:57:46,279] INFO Creating /brokers/ids/1 (is it secure? false) (kafka.utils.ZKCheckedEphemeral)
[2019-01-03 15:57:46,294] INFO Result of znode creation is: NODEEXISTS (kafka.utils.ZKCheckedEphemeral)
[2019-01-03 15:57:46,295] FATAL [Kafka Server 1], Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
java.lang.RuntimeException: A broker is already registered on the path /brokers/ids/1. 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:417)
	at kafka.utils.ZkUtils.registerBrokerInZk(ZkUtils.scala:403)
	at kafka.server.KafkaHealthcheck.register(KafkaHealthcheck.scala:70)
	at kafka.server.KafkaHealthcheck.startup(KafkaHealthcheck.scala:50)
	at kafka.server.KafkaServer.startup(KafkaServer.scala:280)
	at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
	at kafka.Kafka$.main(Kafka.scala:65)
	at kafka.Kafka.main(Kafka.scala)
[2019-01-03 15:57:46,297] INFO [Kafka Server 1], shutting down (kafka.server.KafkaServer)

查了一下,说是 zk 上有节点由于断电没有及时清除,看到 bin 下有 zookeeper-shell.sh,应该可以用这个来搞一搞

$ ./zookeeper-shell.sh 192.168.56.101:2181
Connecting to 192.168.56.101:2181
Welcome to ZooKeeper!
JLine support is disabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

然后删掉节点

rmr /brokers/ids/1
Node does not exist: /brokers/ids/1

发现报错不存在

ls /
[isr_change_notification, zookeeper, admin, consumers, cluster, config, latest_producer_id_block, brokers, controller_epoch]

ls /brokers
[seqid, topics, ids]

ls /brokers/ids
[]

发现 ids 为空

尝试重启 kafka,这次可以了,那应该是在上次不行的时候启动进程自动删除了之类的

Leave a Reply

Your email address will not be published. Required fields are marked *