项目中kafka异常重启导致输出日志报错如下:
[2022-11-04 08:24:31,508] FATAL [KafkaServer id=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.
解决办法
进入bin目录执行zkCli.sh
删除被注册的id即可。
root@c4719e81ea3b:/opt/zookeeper-3.4.9# cd bin
root@c4719e81ea3b:/opt/zookeeper-3.4.9/bin# ./zkCli.sh
Connecting to localhost:2181
[zk: localhost:2181(CONNECTED) 0] ls /brokers/ids
[1]
[zk: localhost:2181(CONNECTED) 1] rmr /brokers/ids/1
[zk: localhost:2181(CONNECTED) 2] ls /brokers/ids
[]
[zk: localhost:2181(CONNECTED) 3] quit
Quitting...
重启kafka后恢复正常