启动kafka集群时报如下错误:
ERROR [KafkaServer id=0] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
java.lang.NoSuchMethodError: org.apache.zookeeper.ZooKeeper.multi(Ljava/lang/Iterable;Lorg/apache/zookeeper/AsyncCallback$MultiCallback;Ljava/lang/Object;)V
at kafka.zookeeper.ZooKeeperClient.send(ZooKeeperClient.scala:213)
at kafka.zookeeper.ZooKeeperClient$$anonfun$handleRequests$1$$anonfun$apply$1.apply$mcV$sp(ZooKeeperClient.scala:144)
at kafka.zookeeper.ZooKeeperClient$$anonfun$handleRequests$1$$anonfun$apply$1.apply(ZooKeeperClient.scala:144)
at kafka.zookeeper.ZooKeeperClient$$anonfun$handleRequests$1$$anonfun$apply$1.apply(ZooKeeperClient.scala:144)
at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:251)
at kafka.utils.CoreUtils$.inReadLock(CoreUtils.scala:257)
at kafka.zookeeper.ZooKeeperClient$$anonfun$handleRequests$1.apply(ZooKeeperClient.scala:143)
at kafka.zookeeper.ZooKeeperClient$$anonfun$handleRequests$1.apply(ZooKeeperClient.scala:140)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
at kafka.zookeeper.ZooKeeperClient.handleRequests(ZooKeeperClient.scala:140)
at kafka.zk.KafkaZkClient.retryRequestsUntilConnected(KafkaZkClient.scala:1660)
at kafka.zk.KafkaZkClient.retryRequestsUntilConnected(KafkaZkClient.scala:1647)
at kafka.zk.KafkaZkClient.retryRequestUntilConnected(KafkaZkClient.scala:1642)
at kafka.zk.KafkaZkClient$CheckedEphemeral.create(KafkaZkClient.scala:1712)
at kafka.zk.KafkaZkClient.checkedEphemeralCreate(KafkaZkClient.scala:1689)
at kafka.zk.KafkaZkClient.registerBroker(KafkaZkClient.scala:97)
at kafka.server.KafkaServer.startup(KafkaServer.scala:260)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
at kafka.Kafka$.main(Kafka.scala:75)
at kafka.Kafka.main(Kafka.scala)
[2020-09-29 09:02:36,476] INFO [KafkaServer id=0] shutting down (kafka.server.KafkaServer)
[2020-09-29 09:02:36,479] INFO [SocketServer brokerId=0] Stopping socket server request processors (kafka.network.SocketServer)
[2020-09-29 09:02:36,486] INFO [SocketServer brokerId=0] Stopped socket server request processors (kafka.network.SocketServer)
[2020-09-29 09:02:36,499] INFO [ReplicaManager broker=0] Shutting down (kafka.server.ReplicaManager)
[2020-09-29 09:02:36,501] INFO [LogDirFailureHandler]: Shutting down (kafka.server.ReplicaManager$LogDirFailureHandler)
[2020-09-29 09:02:36,501] INFO [LogDirFailureHandler]: Stopped (kafka.server.ReplicaManager$LogDirFailureHandler)
[2020-09-29 09:02:36,502] INFO [LogDirFailureHandler]: Shutdown completed (kafka.server.ReplicaManager$LogDirFailureHandler)
[2020-09-29 09:02:36,503] INFO [ReplicaFetcherManager on broker 0] shutting down (kafka.server.ReplicaFetcherManager)
[2020-09-29 09:02:36,505] INFO [ReplicaFetcherManager on broker 0] shutdown completed (kafka.server.ReplicaFetcherManager)
[2020-09-29 09:02:36,506] INFO [ReplicaAlterLogDirsManager on broker 0] shutting down (kafka.server.ReplicaAlterLogDirsManager)
[2020-09-29 09:02:36,507] INFO [ReplicaAlterLogDirsManager on broker 0] shutdown completed (kafka.server.ReplicaAlterLogDirsManager)
[2020-09-29 09:02:36,507] INFO [ExpirationReaper-0-Fetch]: Shutting down (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,641] INFO [ExpirationReaper-0-Fetch]: Stopped (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,641] INFO [ExpirationReaper-0-Fetch]: Shutdown completed (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,642] INFO [ExpirationReaper-0-Produce]: Shutting down (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,841] INFO [ExpirationReaper-0-Produce]: Stopped (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,841] INFO [ExpirationReaper-0-Produce]: Shutdown completed (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,841] INFO [ExpirationReaper-0-DeleteRecords]: Shutting down (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,843] INFO [ExpirationReaper-0-DeleteRecords]: Stopped (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,843] INFO [ExpirationReaper-0-DeleteRecords]: Shutdown completed (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,843] INFO [ExpirationReaper-0-ElectPreferredLeader]: Shutting down (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,845] INFO [ExpirationReaper-0-ElectPreferredLeader]: Stopped (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,845] INFO [ExpirationReaper-0-ElectPreferredLeader]: Shutdown completed (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2020-09-29 09:02:36,857] INFO [ReplicaManager broker=0] Shut down completely (kafka.server.ReplicaManager)
[2020-09-29 09:02:36,861] INFO Shutting down. (kafka.log.LogManager)
[2020-09-29 09:02:36,934] INFO Shutdown complete. (kafka.log.LogManager)
[2020-09-29 09:02:36,941] INFO [ZooKeeperClient] Closing. (kafka.zookeeper.ZooKeeperClient)
[2020-09-29 09:02:36,946] INFO Session: 0x1000163dff20000 closed (org.apache.zookeeper.ZooKeeper)
[2020-09-29 09:02:36,948] INFO EventThread shut down (org.apache.zookeeper.ClientCnxn)
[2020-09-29 09:02:36,953] INFO [ZooKeeperClient] Closed. (kafka.zookeeper.ZooKeeperClient)
[2020-09-29 09:02:36,955] INFO [ThrottledChannelReaper-Fetch]: Shutting down (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,095] INFO [ThrottledChannelReaper-Fetch]: Stopped (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,095] INFO [ThrottledChannelReaper-Fetch]: Shutdown completed (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,095] INFO [ThrottledChannelReaper-Produce]: Shutting down (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,097] INFO [ThrottledChannelReaper-Produce]: Stopped (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,098] INFO [ThrottledChannelReaper-Produce]: Shutdown completed (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,098] INFO [ThrottledChannelReaper-Request]: Shutting down (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,101] INFO [ThrottledChannelReaper-Request]: Stopped (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,101] INFO [ThrottledChannelReaper-Request]: Shutdown completed (kafka.server.ClientQuotaManager$ThrottledChannelReaper)
[2020-09-29 09:02:37,104] INFO [SocketServer brokerId=0] Shutting down socket server (kafka.network.SocketServer)
[2020-09-29 09:02:37,194] INFO [SocketServer brokerId=0] Shutdown completed (kafka.network.SocketServer)
[2020-09-29 09:02:37,205] INFO [KafkaServer id=0] shut down completed (kafka.server.KafkaServer)
[2020-09-29 09:02:37,205] ERROR Exiting Kafka. (kafka.server.KafkaServerStartable)
[2020-09-29 09:02:37,214] INFO [KafkaServer id=0] shutting down (kafka.server.KafkaServer)
原因是启动kafka集群的用户不一致,多次启动导致zookeeper无法守护kafka。
解决方法:
删掉kafka集群每个节点的logs文件
再分别进入kafka集群每个节点的config目录下关闭所有kafka:
kafka-server-stop.sh server.properties
然后关闭在所有节点下关闭所有zookeeper进程。
再重新启动zookeeper集群跟kafka集群
最后问题解决。
如下:
还是不行,多次重复操作即可。