我记得有个demo,如果你用maven就仿照demo。
如果没有,当成jar包放到lib里
你这个是访问被拒呀,文件权限问题。
java.nio.file.AccessDeniedException
如果有新的问题,可以到问题专区里提问呀,这里是文章区域额。
https://www.orchome.com/kafka/issues
还出现了一个新问题, 这个问题一出来就kafka就直接停止了
[2020-12-25 15:54:03,267] FATAL [Replica Manager on Broker 0]: Error writing to highwatermark file: (kafka.server.ReplicaManager)
java.nio.file.FileAlreadyExistsException: C:\kafka_2.11-0.10.0.1\tmp\kafka-logs\replication-offset-checkpoint.tmp -> C:\kafka_2.11-0.10.0.1\tmp\kafka-logs\replication-offset-checkpoint
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:81)
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:1347)
at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:670)
at kafka.server.OffsetCheckpoint.write(OffsetCheckpoint.scala:74)
at kafka.server.ReplicaManager$$anonfun$checkpointHighWatermarks$2.apply(ReplicaManager.scala:889)
at kafka.server.ReplicaManager$$anonfun$checkpointHighWatermarks$2.apply(ReplicaManager.scala:886)
at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:733)
at scala.collection.immutable.Map$Map1.foreach(Map.scala:116)
at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:732)
at kafka.server.ReplicaManager.checkpointHighWatermarks(ReplicaManager.scala:886)
at kafka.server.ReplicaManager$$anonfun$1.apply$mcV$sp(ReplicaManager.scala:163)
at kafka.utils.KafkaScheduler$$anonfun$1.apply$mcV$sp(KafkaScheduler.scala:110)
at kafka.utils.CoreUtils$$anon$1.run(CoreUtils.scala:56)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Suppressed: java.nio.file.AccessDeniedException: C:\kafka_2.11-0.10.0.1\tmp\kafka-logs\replication-offset-checkpoint.tmp -> C:\kafka_2.11-0.10.0.1\tmp\kafka-logs\replication-offset-checkpoint
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
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:1347)
at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:667)
... 17 more
我是spring集成kafka, 关闭的时候都是直接将项目关闭, 我该如何优化的关闭呢? 我看您给的连接中有controlled.shutdown.enable=true这个配置, 我把这个放入server.properties配置文件中还是会出现这个问题
缓存和索引不匹配,你是不是没有优雅停机,不过是警告,可以忽视。
https://www.orchome.com/32