Problem description
Kafka deployed in Windows environment hangs up after running for a period of time
view logs logs/server Log
the following errors are found:
ERROR Failed to clean up log for __consumer_offsets-44 in dir D:\kafka\kafka_2.13-2.8.0\kafkakafka_2.13-2.8.0kafka-logs due to IOException (kafka.server.LogDirFailureChannel)
java.nio.file.FileSystemException: D:\kafka\kafka_2.13-2.8.0\kafkakafka_2.13-2.8.0kafka-logs\__consumer_offsets-44\00000000000000000000.timeindex.cleaned -> D:\kafka\kafka_2.13-2.8.0\kafkakafka_2.13-2.8.0kafka-logs\__consumer_offsets-44\00000000000000000000.timeindex.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:904)
at kafka.log.AbstractIndex.renameTo(AbstractIndex.scala:210)
at kafka.log.LazyIndex$IndexValue.renameTo(LazyIndex.scala:155)
at kafka.log.LazyIndex.$anonfun$renameTo$1(LazyIndex.scala:79)
at kafka.log.LazyIndex.renameTo(LazyIndex.scala:79)
at kafka.log.LogSegment.changeFileSuffixes(LogSegment.scala:496)
at kafka.log.Log.$anonfun$replaceSegments$4(Log.scala:2402)
at kafka.log.Log.$anonfun$replaceSegments$4$adapted(Log.scala:2402)
at scala.collection.immutable.List.foreach(List.scala:333)
at kafka.log.Log.replaceSegments(Log.scala:2402)
at kafka.log.Cleaner.cleanSegments(LogCleaner.scala:613)
at kafka.log.Cleaner.$anonfun$doClean$6(LogCleaner.scala:538)
at kafka.log.Cleaner.$anonfun$doClean$6$adapted(LogCleaner.scala:537)
at scala.collection.immutable.List.foreach(List.scala:333)
at kafka.log.Cleaner.doClean(LogCleaner.scala:537)
at kafka.log.Cleaner.clean(LogCleaner.scala:511)
at kafka.log.LogCleaner$CleanerThread.cleanLog(LogCleaner.scala:380)
at kafka.log.LogCleaner$CleanerThread.cleanFilthiestLog(LogCleaner.scala:352)
at kafka.log.LogCleaner$CleanerThread.tryCleanFilthiestLog(LogCleaner.scala:332)
at kafka.log.LogCleaner$CleanerThread.doWork(LogCleaner.scala:321)
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:96)
Suppressed: java.nio.file.FileSystemException: D:\kafka\kafka_2.13-2.8.0\kafkakafka_2.13-2.8.0kafka-logs\__consumer_offsets-44\00000000000000000000.timeindex.cleaned -> D:\kafka\kafka_2.13-2.8.0\kafkakafka_2.13-2.8.0kafka-logs\__consumer_offsets-44\00000000000000000000.timeindex.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:901)
... 20 more
reason
When the consumer offsets the log cleanup or the log file scrolls, Kafka broker will shut down because the file renaming fails. This is because cannot modify the file
in use in windows.
Solution
In server In the properties
configuration file:
1.Modify log retention. Hours = - 1
2.Add log at the end of the file cleaner. Enable = false
3.Restart
Suggestion
There are similar issues and PR in GitHub, but they are not merged. The author uses kafka_2.13-2.8.0
version has this problem. Kafka is not recommended for win environments.
Read More:
- [Solved] Docker Elasticsearch8.4.0 Error: Exception in thread “main” java.nio.file.FileSystemException
- [Solved] Error: caused by: java.net.bindexception: the address is already in use
- [Solved] kafka Error: java.net.UnknownHostException: ls-bptysztw
- kafka Environment Build and Startup Error: ERROR [KafkaServer id=1] Fatal error during KafkaServer startup. Prepare to shutdown
- [Solved] kafka Error: java.net.UnknownHostException: kafkahost
- [Solved] Spring Kafka Send Error in specifies partition: Topic radar not present in metadata after 60000
- [Solved] Kafka Error: is/are not present and missingTopicsFatal is true
- java.util.zip.zipexception: error in opening zip file
- kakfa Create topic Error: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 3 larger than available brokers: 2.
- Java parsing xml file encounters special symbols & will be abnormal solutions
- Java error: unable to find or load main class (package name in source file)
- [Solved] kafka startup Error: ERROR Fatal error during KafkaServer startup. Prepare to shutdown
- How to Open Files by Dragging and Dropping in C#
- [Solved] ClientAbortException: java.io.IOException: Connection reset by peer
- Caused by: java.lang.IllegalStateException (How to Fix)
- [Solved] JAVA connect HBase program is stuck and does not report an error
- JAVA: Random access file is always garbled
- Split log by date in log4j2 of spring boot
- [Solved] fasterxml ToStringSerializerBase Error: Caused by: java.lang.NoClassDefFoundError…
- The Java class generated by protocol reports an error: cannot access