最近在启动zookeeper时,突然报了个错
ERROR Unexpected exception, exiting abnormally (org.apache.zookeeper.server.ZooKeeperServerMain)
java.io.IOException: No snapshot found, but there are log entries. Something is broken!
at org.apache.zookeeper.server.persistence.FileTxnSnapLog.restore(FileTxnSnapLog.java:222)
at org.apache.zookeeper.server.ZKDatabase.loadDataBase(ZKDatabase.java:240)
at org.apache.zookeeper.server.ZooKeeperServer.loadData(ZooKeeperServer.java:290)
at org.apache.zookeeper.server.ZooKeeperServer.startdata(ZooKeeperServer.java:450)
at org.apache.zookeeper.server.NIOServerCnxnFactory.startup(NIOServerCnxnFactory.java:764)
at org.apache.zookeeper.server.ServerCnxnFactory.startup(ServerCnxnFactory.java:98)
at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:144)
at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:106)
at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:64)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:128)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:82)
解决方法:删除zookeeper.properties中相应的dataDir目录,比如Windows:D:\Kafka\zk-data 把D盘的zk-data目录删除,如果没用就删kafka/bin/windows/Kafka-data
删完后启动kafka会报错:
[2024-07-10 11:43:15,276] INFO Cluster ID = rVm18xERQb-qIrd4zCbWTw (kafka.server.KafkaServer)
[2024-07-10 11:43:15,286] ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.common.InconsistentClusterIdException: The Cluster ID rVm18xERQb-qIrd4zCbWTw doesn't match stored clusterId Some(bxAhIaewRVGT1vvkXv7RLQ) in meta.properties. The broker is trying to join the wrong cluster. Configured zookeeper.connect may be wrong.
at kafka.server.KafkaServer.startup(KafkaServer.scala:244)
at kafka.Kafka$.main(Kafka.scala:113)
at kafka.Kafka.main(Kafka.scala)
[2024-07-10 11:43:15,289] INFO shutting down (kafka.server.KafkaServer)
[2024-07-10 11:43:15,294] INFO [ZooKeeperClient Kafka server] Closing. (kafka.zookeeper.ZooKeeperClient)
[2024-07-10 11:43:15,414] INFO Session: 0x1000afa40ed0002 closed (org.apache.zookeeper.ZooKeeper)
[2024-07-10 11:43:15,414] INFO EventThread shut down for session: 0x1000afa40ed0002 (org.apache.zookeeper.ClientCnxn)
[2024-07-10 11:43:15,422] INFO [ZooKeeperClient Kafka server] Closed. (kafka.zookeeper.ZooKeeperClient)
[2024-07-10 11:43:15,440] INFO App info kafka.server for 0 unregistered (org.apache.kafka.common.utils.AppInfoParser)
[2024-07-10 11:43:15,443] INFO shut down completed (kafka.server.KafkaServer)
[2024-07-10 11:43:15,448] ERROR Exiting Kafka due to fatal exception during startup. (kafka.Kafka$)
kafka.common.InconsistentClusterIdException: The Cluster ID rVm18xERQb-qIrd4zCbWTw doesn't match stored clusterId Some(bxAhIaewRVGT1vvkXv7RLQ) in meta.properties. The broker is trying to join the wrong cluster. Configured zookeeper.connect may be wrong.
at kafka.server.KafkaServer.startup(KafkaServer.scala:244)
at kafka.Kafka$.main(Kafka.scala:113)
at kafka.Kafka.main(Kafka.scala)
[2024-07-10 11:43:15,455] INFO shutting down (kafka.server.KafkaServer)
解决方法:删除server.properties中dataDir,如果没用删kafka/bin/windows/Kafka-logs