zookeeper + Kafka - Unable to create data directory
Asked Answered
K

13

13

I´m using zookeeper 3.4.8 in single node and try to use kafka.

When I run this command:

zookeeper-server-start.sh /usr/local/kafka_2.9.2-0.8.2.2    /config/zookeeper.properties

I get the below error:

[2016-02-22 17:32:41,661] ERROR Unexpected exception, exiting abnormally (org.apache.zookeeper.server.ZooKeeperServerMain)
java.io.IOException: Unable to create data directory /var/zookeeper/version-2
    at org.apache.zookeeper.server.persistence.FileTxnSnapLog.<init>(FileTxnSnapLog.java:85)
    at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:104)
    at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:86)
    at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:52)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:116)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)

Any advice?

Kilbride answered 22/2, 2016 at 19:1 Comment(1)
Sounds like a permissions problem. Can you perform the command if you sudo it?Fenian
F
30

One reason could be the inappropriate path specified to zoo.config file. A lot of solutions on the web specifies the path as ":\zookeeper-3.4.7\data".

Instead of the above mentioned format, specify the address as full path from your C: drive to the data folder. It worked for me. (Don't forget to put double slash \ instead of one in case you're on windows)

Furtado answered 6/8, 2017 at 8:33 Comment(1)
This was exactly the case and it was fixed. Sharing my correct data dir: "dataDir= C:\\Program Files\Apache Zookeeper\zookeeper-3.4.11\data"Homograft
A
8

I got this problem for this setting on Windows PC:

dataDir=c:/data/zoo/

and thus this error:

2016-12-02 15:29:25,327 [myid:] - ERROR [main:ZooKeeperServerMain@64] - Unexpected exception, exiting abnormally
java.io.IOException: Unable to create data directory ??:\data\zoo\version-2

Problem was solved by changing (I have ZooKeeper on C disk unpackaged)

dataDir=/data/zoo/

Also run command line tool as Administrator if needed

Arteriole answered 2/12, 2016 at 13:35 Comment(0)
B
4

I faced the same issue, and this works with

sudo bin/zookeeper-server-start.sh config/zookeeper.properties

Beverleebeverley answered 25/7, 2019 at 10:23 Comment(1)
Nice insight. Is this also a good advice for the OP?Lawabiding
L
3

You probably don't have permission to write to the directory log.dirs (see zookeeper.properties). Change the directory to a different one, change the permission setting of the current log.dirs directory or run Kafka as different user. You can use the command ls -l /var/zookeeper to see the current permissions and then chmod to change the permissions.

Lutist answered 22/2, 2016 at 19:41 Comment(1)
I'm glad that it works but I'd recommend to change the folder permissions instead of running Zookeeper as sudo.Springwood
T
2

The reason is that zookeeper has no permission. Trying to use the administrator role to install it.

Tabu answered 13/4, 2019 at 13:12 Comment(0)
G
1

For windows, set dataDir to full path where you have no access restrictions - with no quotes("")

dataDir=C:\\your-path\
dataDir=C:\\zk\tmp\

Note: I have observed the command to fail for some of the path(though full access) and running command prompt as administrator has solved it.

Gobbet answered 14/2, 2020 at 2:28 Comment(0)
M
1

For window's machine

Solved : Use double slashes inside the path while defining the dataDir path

dataDir=E:\\tools\\zookeeperdata\\data

Mysia answered 10/3, 2022 at 9:37 Comment(0)
T
0

And in my windows 10 system, using zookeeper 3.4.10. the dataDir attribute should setting like :\\\\zookeeper\\\\data, not d:\zookeeper\data. it also can setting as linux file system separator(d:/zookeeper/data). then this problem should be ok. And in linux, I think it permission problem. also it can come across when dataDir is under driver C in windows system.

Testaceous answered 13/3, 2018 at 12:6 Comment(0)
O
0

If you're running the zookeeper in the Windows 10 machine we need to specify the dataDir property something like this

"dataDir=C:\zookeeper-3.4.13\data"

Officiate answered 27/7, 2018 at 10:29 Comment(0)
O
0

In my windows 10 system, using zookeeper 3.4.13, the following example path is working:

"dataDir=C:\\dev\\tools\\zookeeper-3.4.13\\data"

You have to use double backslashes.

Oceania answered 29/11, 2018 at 13:45 Comment(0)
E
0

on zoo.cfg you need to change directory to above or anything similar:

dataDir=C:/zookeeper-3.4.14/zookeeper-3.4.14/data
Enkindle answered 26/11, 2019 at 20:0 Comment(0)
P
0

I was running into this problem due to my docker desktop being out of diskspace.

Running:

docker system prune

Resolved the issue for me.

Prayerful answered 5/4 at 19:51 Comment(0)
S
-1

For windows the below too works:

dataDir=C:\\zookeeper-3.4.14\\zookeeper-3.4.14\\data
Shrimp answered 13/4, 2019 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.