启动kafka时报错:java.nio.file.FileSystemException,另一个程序正在使用此文件,进程无法访问。

先贴上错误信息

[2018-08-12 10:04:52,070] ERROR Failed to clean up log for __consumer_offsets-4 in dir D:\tmp\kafka-logs due to IOException (kafka.server.LogDirFailureChannel)
java.nio.file.FileSystemException: D:\tmp\kafka-logs\__consumer_offsets-4\00000000000000000000.log.cleaned -> D:\tmp\kafka-logs\__consumer_offsets-4\00000000000000000000.log.swap: 另一个程序正在使用此文件,进程无法访问。

	at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
	at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387)
	at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
	at java.nio.file.Files.move(Files.java:1395)
	at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:697)
	at org.apache.kafka.common.record.FileRecords.renameTo(FileRecords.java:212)
	at kafka.log.LogSegment.changeFileSuffixes(LogSegment.scala:415)
	at kafka.log.Log.replaceSegments(Log.scala:1644)
	at kafka.log.Cleaner.cleanSegments(LogCleaner.scala:535)
	at kafka.log.Cleaner.$anonfun$doClean$6(LogCleaner.scala:462)
	at kafka.log.Cleaner.$anonfun$doClean$6$adapted(LogCleaner.scala:461)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at kafka.log.Cleaner.doClean(LogCleaner.scala:461)
	at kafka.log.Cleaner.clean(LogCleaner.scala:438)
	at kafka.log.LogCleaner$CleanerThread.cleanOrSleep(LogCleaner.scala:305)
	at kafka.log.LogCleaner$CleanerThread.doWork(LogCleaner.scala:291)
	at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:82)
	Suppressed: java.nio.file.FileSystemException: C:\tmp\kafka-logs\__consumer_offsets-4\00000000000000000000.log.cleaned -> C:\tmp\kafka-logs\__consumer_offsets-4\00000000000000000000.log.swap: 另一个程序正在使用此文件,进程无法访问。

		at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
		at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
		at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:301)
		at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
		at java.nio.file.Files.move(Files.java:1395)
		at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:694)
		... 12 more

原因分析:未能清理 D:\tmp\kafka-logs目录中的consumer_offset记录
consumer_offset是kafka自动保存偏移量的topic,自带的topic
设定目录是在config/server.config下的logs.dirs
在这里插入图片描述
图片中是我修改之后的路径,原来的路径是/tmp/logs

解决方法::手动删除目录下的所有文件,重启kafka

你可能感兴趣的:(kafka)