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?

Ishan Pathak
  • 85
  • 1
  • 1
  • 2
  • 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 actions – OneCricketeer May 16 '21 at 12:33

3 Answers3

10

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

user17588888
  • 101
  • 1
  • 2
2

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

Transformer
  • 6,963
  • 2
  • 26
  • 52
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

Tyler2P
  • 2,324
  • 26
  • 22
  • 31