zookeeper + Kafka - Unable to create data directory

痴心易碎 提交于 2019-12-23 15:41:04

问题


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?


回答1:


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)




回答2:


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




回答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.




回答4:


Running Kafka on GCE. Simply add sudo and it worked for me.




回答5:


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




回答6:


I faced the same issue, and this works with

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




回答7:


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.




回答8:


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"




回答9:


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.




回答10:


For windows the below too works:

dataDir=C:\\zookeeper-3.4.14\\zookeeper-3.4.14\\data



回答11:


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

dataDir=C:/zookeeper-3.4.14/zookeeper-3.4.14/data


来源:https://stackoverflow.com/questions/35561723/zookeeper-kafka-unable-to-create-data-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!