Getting java.nio.file.AccessDeniedException on kafka on Windows
Asked Answered
C

5

8

I tried to setup kafka and zookeeper on windows. Initially I created topics, producers and consumers. It was working fine. Then I deleted one topic by using the below command:

kafka-run-class.bat kafka.admin.TopicCommand --delete --topic junk --zookeeper localhost:2181

Now every time I re-run the kafka, it gets terminated with the below error: java.nio.file.AccessDeniedException: C:\kafka_2.12-2.8.0\kafka_2.12-2.8.0kafka-logs\junk-0 -> C:\kafka_2.12-2.8.0\kafka_2.12-2.8.0kafka-logs\junk-0.305f67a1260f4cccb87d9367c6619fd2-delete

I tried to remove the zookeper and kafka directory and use a fresh directory for both. But somehow its retaining the previous saved topics and logs (I don't know what location they're stored at).

Could anyone tell me how to fix this?

Celie answered 16/5, 2021 at 9:42 Comment(1)
Please show your broker server.properties file. By default, Kafka stores data in /tmp, which obviously doesn't exist on windows. Also the error tells you exactly what files are being acted on, so do those actually exist? And, by the way, you shouldn't be using deprecated Zookeeper flag on cli actionsErma
O
11

I also faced the same issue with new version kafka_2.12-3.0.0. Sorted out by using lower version kafka_2.12-2.8.1

Overstuff answered 4/12, 2021 at 15:49 Comment(0)
D
3

Login as admin, and try the below topic path/location the logs and

  1. delete it manually or delete all your logs (both kafka & zookeeper logs) if you want to try fresh

/tmp/kafka-logs/[yourTopics] // Delete *** Kafka Logs

Now go back and try again. If you are still running into the problem then disable the cleaner

log.cleaner.enable = false

  1. Next, I would recommend stopping all services and then type %temp% in windows command, and delete all the temp files as well

in linux

// find stale files older than for more than `7 days` 
// and deletes those, not folders. 
sudo find /tmp -type f -atime +7-delete
  1. Finally, you will need to delete the zookeeper logs and kill the running zoo keeper process see this answer here are you using the confluent stack?

 // kill the zookeeper process
  ps aux | grep zookeeper
  sudo kill -9 <PID>     // or windows admin

 // find and delete **** ZooKeeper logs
  ps -ef | grep zookeeper | grep zookeeper.log.dir --color    
  lsof -p <pid of zookeeper> | grep log
  lsof -p <pid of zookeeper> | grep out

Update to comment below - yes you can run on windows, with the WSL 2 subsystem/Linux 2 link from official confluent site

Kafka on Windows

Diminution answered 16/5, 2021 at 19:49 Comment(1)
Confluent Platform doesn't support Windows, btwErma
M
0

I am assuming that your Kafka server is being tied to Zookeeper. If true then we get this error when any topic was deleted.

To resolve this issue, we need to delete data directory folder configured in apache-zookeeper-home\conf\zoo.cfg file

Meditate answered 4/6, 2022 at 5:52 Comment(0)
C
0

I had this problem today and it appeared to be resolved by restarting zookeeper & kafka from within the C:\kafka_version\bin directory

Chiapas answered 18/1 at 10:39 Comment(0)
M
0

Step 1: Terminate all command prompts which runs zookeeper, kafka server and close all of them
Step 2: Go to the folder where both zookeeper folder & kafka-logs are present and delete it [You can find the path in server.properties and zookeeper.properties]
Step 3: Now try running again, it must work

Maudemaudie answered 5/5 at 18:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.