Programming/Kafka

[kafka] window에서 사용시 java.nio.file.FileSystemException

bisi 2020. 4. 3. 17:52

현상

window에서 kafka 정상 시작은 되었지만, 몇일 뒤 아래와 같은 오류로 kafka 강제 종료되었다. 

 

[2020-03-25 09:34:24,966] INFO Starting server (org.apache.zookeeper.server.ZooKeeperServerMain)
.................

[2020-04-01 10:52:09,979] ERROR Error while deleting segments for test-0 in dir D:\tmp\kafka-logs (kafka.server.LogDirFailureChannel) java.nio.file.FileSystemException: D:\tmp\kafka-logs\test-0\00000000000000000000.timeindex -> D:\tmp\kafka-logs\test-0\00000000000000000000.timeindex.deleted: ՙإ ȁ؎ܼݺС DŽO; ܧࠫ ŸLҢ ֧ٮߡ ȁ؎ܼݺС ߗܼݺ Ȓ ݶ ߸ހՏՙ. 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:805) at kafka.log.AbstractIndex.renameTo(AbstractIndex.scala:205) at kafka.log.LogSegment.changeFileSuffixes(LogSegment.scala:490) at kafka.log.Log.asyncDeleteSegment(Log.scala:1924) at kafka.log.Log.deleteSegment(Log.scala:1909) at kafka.log.Log.$anonfun$deleteSegments$3(Log.scala:1455) at kafka.log.Log.$anonfun$deleteSegments$3$adapted(Log.scala:1455) at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62) at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55) at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49) at kafka.log.Log.$anonfun$deleteSegments$2(Log.scala:1455) at scala.runtime.java8.JFunction0$mcI$sp.apply(JFunction0$mcI$sp.java:23) at kafka.log.Log.maybeHandleIOException(Log.scala:2013) at kafka.log.Log.deleteSegments(Log.scala:1446) at kafka.log.Log.deleteOldSegments(Log.scala:1441) at kafka.log.Log.deleteRetentionMsBreachedSegments(Log.scala:1519) at kafka.log.Log.deleteOldSegments(Log.scala:1509) at kafka.log.LogManager.$anonfun$cleanupLogs$3(LogManager.scala:913) at kafka.log.LogManager.$anonfun$cleanupLogs$3$adapted(LogManager.scala:910) at scala.collection.immutable.List.foreach(List.scala:392) at kafka.log.LogManager.cleanupLogs(LogManager.scala:910) at kafka.log.LogManager.$anonfun$startup$2(LogManager.scala:395) at kafka.utils.KafkaScheduler.$anonfun$schedule$2(KafkaScheduler.scala:114) at kafka.utils.CoreUtils$$anon$1.run(CoreUtils.scala:63) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Suppressed: java.nio.file.FileSystemException: D:\tmp\kafka-logs\test-0\00000000000000000000.timeindex -> D:\tmp\kafka-logs\test-0\00000000000000000000.timeindex.deleted: ՙإ ȁ؎ܼݺС DŽO; ܧࠫ ŸLҢ ֧ٮߡ ȁ؎ܼݺС ߗܼݺ Ȓ ݶ ߸ހՏՙ. 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:802) ... 30 more [2020-04-01 10:52:10,171] ERROR Uncaught exception in scheduled task 'kafka-log-retention' (kafka.utils.KafkaScheduler) org.apache.kafka.common.errors.KafkaStorageException: Error while deleting segments for test-0 in dir D:\tmp\kafka-logs Caused by: java.nio.file.FileSystemException: D:\tmp\kafka-logs\test-0\00000000000000000000.timeindex -> D:\tmp\kafka-logs\test-0\00000000000000000000.timeindex.deleted: ՙإ ȁ؎ܼݺС DŽO; ܧࠫ ŸLҢ ֧ٮߡ ȁ؎ܼݺС ߗܼݺ Ȓ ݶ ߸ހՏՙ. 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:805) at kafka.log.AbstractIndex.renameTo(AbstractIndex.scala:205) at kafka.log.LogSegment.changeFileSuffixes(LogSegment.scala:490) at kafka.log.Log.asyncDeleteSegment(Log.scala:1924) at kafka.log.Log.deleteSegment(Log.scala:1909) at kafka.log.Log.$anonfun$deleteSegments$3(Log.scala:1455) at kafka.log.Log.$anonfun$deleteSegments$3$adapted(Log.scala:1455) at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62) at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55) at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49) at kafka.log.Log.$anonfun$deleteSegments$2(Log.scala:1455) at scala.runtime.java8.JFunction0$mcI$sp.apply(JFunction0$mcI$sp.java:23) at kafka.log.Log.maybeHandleIOException(Log.scala:2013) at kafka.log.Log.deleteSegments(Log.scala:1446) at kafka.log.Log.deleteOldSegments(Log.scala:1441) at kafka.log.Log.deleteRetentionMsBreachedSegments(Log.scala:1519) at kafka.log.Log.deleteOldSegments(Log.scala:1509) at kafka.log.LogManager.$anonfun$cleanupLogs$3(LogManager.scala:913) at kafka.log.LogManager.$anonfun$cleanupLogs$3$adapted(LogManager.scala:910) at scala.collection.immutable.List.foreach(List.scala:392) at kafka.log.LogManager.cleanupLogs(LogManager.scala:910) at kafka.log.LogManager.$anonfun$startup$2(LogManager.scala:395) at kafka.utils.KafkaScheduler.$anonfun$schedule$2(KafkaScheduler.scala:114) at kafka.utils.CoreUtils$$anon$1.run(CoreUtils.scala:63) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Suppressed: java.nio.file.FileSystemException: D:\tmp\kafka-logs\test-0\00000000000000000000.timeindex -> D:\tmp\kafka-logs\test-0\00000000000000000000.timeindex.deleted: ՙإ ȁ؎ܼݺС DŽO; ܧࠫ ŸLҢ ֧ٮߡ ȁ؎ܼݺС ߗܼݺ Ȓ ݶ ߸ހՏՙ. 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:802) ... 30 more

 

 

해결방법

 

1. OS 변경 Window -> Linux 

 

kafka는 리눅스 환경이 더 안정적이고, Window에서는 주의해야할점이 몇가지가 있다. 

(window 폴더 안에 있는 bat파일로 실행, 파일명 길면 실행안됨 등등)

 

kafka 개발은 linux나 도커 환경에서 진행하는걸 추천한다. 

 

2. log.dirs의 폴더경로를 변경하거나 log.dirs에 있는 모든 파일을 삭제한다.

이 방법도 썩 추천하고 싶지 않은 방법이다.

 

 

 

 

참고 사이트 

Kafka: unable to start Kafka - process can not access file 00000000000000000000.timeindex

KAFKA는 윈도우즈에서는 정상동작 하지 않음