今天在启动kafka是报如下错误:
org.apache.kafka.common.KafkaException: Failed to acquire lock on file .lock in /home/software/kafka/datas. A Kafka instance in another process or thread is using this directory.
ERROR [KafkaServer id=0] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.K afkaServer)
org.apache.kafka.common.KafkaException: Failed to acquire lock on file .lock in /home/software/kafka/datas. A Kafka instance i n another process or thread is using this directory.
at kafka.log.LogManager.$anonfun$lockLogDirs$1(LogManag er.scala:241)
at scala.collection.TraversableLike.$anonfun$flatMap$1( TraversableLike.scala:293)
at scala.collection.mutable.ResizableArray.foreach(Resi zableArray.scala:62)
at scala.collection.mutable.ResizableArray.foreach$(Res izableArray.scala:55)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBu ffer.scala:49)
at scala.collection.TraversableLike.flatMap(Traversable Like.scala:293)
at scala.collection.TraversableLike.flatMap$(Traversabl eLike.scala:290)
at scala.collection.AbstractTraversable.flatMap(Travers able.scala:108)
at kafka.log.LogManager.lockLogDirs(LogManager.scala:23 6)
at kafka.log.LogManager.<init>(LogManager.scala:112)
at kafka.log.LogManager$.apply(LogManager.scala:1315)
at kafka.server.KafkaServer.startup(KafkaServer.scala:2 59)
at kafka.Kafka$.main(Kafka.scala:109)
at kafka.Kafka.main(Kafka.scala)
这个错误原因是之前启动的kafka未正常关闭,导致无法启动,需要查看一下已有的进程,将该kafka进程kill掉,再重新启动即可: