在windows kafka上删除主题时发生accessdeniedexception

bn31dyow  于 2021-06-08  发布在  Kafka
关注(0)|答案(4)|浏览(782)

我刚刚在我的windows机器上安装了kafka(来自合流平台)。我创办了zookeeper和kafka,并创建了主题,制作和消费它们的作品。然而,我一删除一个主题,Kafka就会崩溃如下:

PS C:\confluent-4.1.1> .\bin\windows\kafka-topics.bat -zookeeper 127.0.0.1:2181 --topic foo --create --partitions 1 --replication-factor 1
Created topic "foo".
PS C:\confluent-4.1.1> .\bin\windows\kafka-topics.bat -zookeeper 127.0.0.1:2181 --topic foo --delete
Topic foo is marked for deletion.
Note: This will have no impact if delete.topic.enable is not set to true.

这是崩溃输出:

[2018-06-08 09:44:54,185] ERROR Error while renaming dir for foo-0 in log dir C:\confluent-4.1.1\data\kafka (kafka.server.LogDirFailureChannel)
java.nio.file.AccessDeniedException: C:\confluent-4.1.1\data\kafka\foo-0 -> C:\confluent-4.1.1\data\kafka\foo-0.cf697a92ed5246c0977bf9a279f15de8-delete
        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: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 kafka.log.Log$$anonfun$renameDir$1.apply$mcV$sp(Log.scala:579)
        at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:577)
        at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:577)
        at kafka.log.Log.maybeHandleIOException(Log.scala:1678)
        at kafka.log.Log.renameDir(Log.scala:577)
        at kafka.log.LogManager.asyncDelete(LogManager.scala:828)
        at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:240)
        at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:235)
        at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:250)
        at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:258)
        at kafka.cluster.Partition.delete(Partition.scala:235)
        at kafka.server.ReplicaManager.stopReplica(ReplicaManager.scala:347)
        at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:377)
        at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:375)
        at scala.collection.Iterator$class.foreach(Iterator.scala:891)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at kafka.server.ReplicaManager.stopReplicas(ReplicaManager.scala:375)
        at kafka.server.KafkaApis.handleStopReplicaRequest(KafkaApis.scala:205)
        at kafka.server.KafkaApis.handle(KafkaApis.scala:116)
        at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69)
        at java.lang.Thread.run(Thread.java:748)
        Suppressed: java.nio.file.AccessDeniedException: C:\confluent-4.1.1\data\kafka\foo-0 -> C:\confluent-4.1.1\data\kafka\foo-0.cf697a92ed5246c0977bf9a279f15de8-delete
                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:1395)
                at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:694)
                ... 23 more
[2018-06-08 09:44:54,187] INFO [ReplicaManager broker=0] Stopping serving replicas in dir C:\confluent-4.1.1\data\kafka (kafka.server.ReplicaManager)
[2018-06-08 09:44:54,192] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions  (kafka.server.ReplicaFetcherManager)
[2018-06-08 09:44:54,193] INFO [ReplicaAlterLogDirsManager on broker 0] Removed fetcher for partitions  (kafka.server.ReplicaAlterLogDirsManager)
[2018-06-08 09:44:54,195] INFO [ReplicaManager broker=0] Broker 0 stopped fetcher for partitions  and stopped moving logs for partitions  because they are in the failed log directory C:\confluent-4.1.1\data\kafka. (kafka.server.ReplicaManager)
[2018-06-08 09:44:54,195] INFO Stopping serving logs in dir C:\confluent-4.1.1\data\kafka (kafka.log.LogManager)
[2018-06-08 09:44:54,197] ERROR Shutdown broker because all log dirs in C:\confluent-4.1.1\data\kafka have failed (kafka.log.LogManager)
[2018-06-08 09:44:54,198] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions  (kafka.server.ReplicaFetcherManager)

运行zookeeper和kafka的用户对 C:\confluent-4.1.1\data\kafka .
我错过了什么?

qyyhg6bp

qyyhg6bp1#

问题:删除一个主题后,我也遇到了类似的问题。zookeeper启动成功,但在运行kafka时,我遇到了上述问题。
分析:在我的例子中,我将kafka日志重定向到新文件夹位置c:\tools\kafka\u 2.13-2.6.0\kafka test logs。我忘了创建一个文件夹kafka测试日志。在本例中,它将使用提供的路径名创建自动默认文件夹,例如:toolskafkaèu 2.13-2.6.0kafka-test-logs。所以即使删除了这个logs文件夹在我的情况下也不起作用。
解决方法:首先我停止了Zookeeper。我创建了一个新的文件夹kafka test logs,我之前忘记了它,然后删除了为kafka创建的默认日志,然后重新启动zookeeper和kafka服务器。这些都对我有用。
谢谢您!!干杯,快乐编码。

dgtucam1

dgtucam12#

我有一个类似的问题,它只发生在windows下,见kafka-1194,它仍然适用于kafka 1.1.0
唯一可用的解决方法是禁用清洁器 log.cleaner.enable = false 对于windows下的本地开发,您可以忽略此问题,因为它不适用于其他操作系统。

mspsb9vt

mspsb9vt3#

在删除一个主题之后,我也遇到了类似的问题。我不得不去主题的位置,并删除它手动和它的工作。 /tmp/kafka-logs/[yourTopicName] 我不确定是否同样适用于你们,因为我也是Kafka的新人。

mf98qq94

mf98qq944#

我知道我来晚了,但请记住,即使你手动删除你的主题或通过一些Kafka用户界面,你删除了所有Kafka日志,Kafka仍然可能无法启动,因为它与zk同步的状态。
因此,请确保通过删除zk的日志来清除zk状态。
请知道这些行为是不可逆转的。同时以管理员身份运行

相关问题