[Solved] kafka startup Error: ERROR Fatal error during KafkaServer startup. Prepare to shutdown

1. Error Message:

ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.common.InconsistentBrokerIdException: Configured broker.id 0 doesn’t match stored broker.id Some(1) in meta.properties. If you moved your data, make sure your configured broker.id matches. If you intend to create a new broker, you should remove all data in your data directories (log.dirs).
at kafka.server.KafkaServer.getOrGenerateBrokerId(KafkaServer.scala:793)
at kafka.server.KafkaServer.startup(KafkaServer.scala:221)
at kafka.Kafka$.main(Kafka.scala:109)
at kafka.Kafka.main(Kafka.scala)

 

2. Casue
The id value inside meta.properties (path: /opt/kafka/logs) does not match the broker.id in server.properties of /opt/kafka/config.

The cause is this: due to the mistaken deletion of the file on linux, so that _cd_ such a command can not be used, but fortunately there are other nodes can be used, after some backtracking, successfully run zookeeper, however, when running kafka, reported an error ERROR Fatal error during KafkaServer Prepare to shutdown, the first line of the error message is as follows.

The reason for this is that the id value in the meta.properties (path: /opt/kafka/logs) does not match the broker.id in the server.properties in /opt/kafka/config.
This is after I modified it, originally it was broker.id=1

 

3. System prompt

    [2022-06-18 14:32:02,309] ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)kafka.common.InconsistentBrokerIdException: Configured broker.id 0 doesn’t match stored broker.id Some(1) in meta.properties. If you moved your data, make sure your configured broker.id                      matches. If you intend to create a new broker, you should remove all data in your data directories (log.dirs).        at kafka.server.KafkaServer.getOrGenerateBrokerId(KafkaServer.scala:793)        at kafka.server.KafkaServer.startup(KafkaServer.scala:221)        at kafka.Kafka$.main(Kafka.scala:109)        at kafka.Kafka.main(Kafka.scala)[2022-06-18 14:32:02,323] INFO shutting down (kafka.server.KafkaServer)[2022-06-18 14:32:02,354] INFO [feature-zk-node-event-process-thread]: Shutting down (kafka.server.FinalizedFeatureChangeListener$ChangeNotificationProcessorThread)[2022-06-18 14:32:02,360] INFO [feature-zk-node-event-process-thread]: Stopped (kafka.server.FinalizedFeatureChangeListener$ChangeNotificationProcessorThread)[2022-06-18 14:32:02,383] INFO [feature-zk-node-event-process-thread]: Shutdown completed (kafka.server.FinalizedFeatureChangeListener$ChangeNotificationProcessorThread)[2022-06-18 14:32:02,406] INFO [ZooKeeperClient Kafka server] Closing. (kafka.zookeeper.ZooKeeperClient)[2022-06-18 14:32:02,568] INFO Session: 0x1000059c2cd0000 closed (org.apache.zookeeper.ZooKeeper)[2022-06-18 14:32:02,583] INFO EventThread shut down for session: 0x1000059c2cd0000 (org.apache.zookeeper.ClientCnxn)[2022-06-18 14:32:02,588] INFO [ZooKeeperClient Kafka server] Closed. (kafka.zookeeper.ZooKeeperClient)[2022-06-18 14:32:02,621] INFO App info kafka.server for 0 unregistered (org.apache.kafka.common.utils.AppInfoParser)[2022-06-18 14:32:02,624] INFO shut down completed (kafka.server.KafkaServer)[2022-06-18 14:32:02,625] ERROR Exiting Kafka. (kafka.Kafka$)[2022-06-18 14:32:02,655] INFO shutting down (kafka.server.KafkaServer)

4. Solution
Found the reason, broker=0 and broker.id=1 modified to the same value, and then restart, ERROR Fatal error during KafkaServer startup.

Read More: