zookeeper + Kafka - Unable to create data director

2019-06-24 15:11发布

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?

9条回答
forever°为你锁心
2楼-- · 2019-06-24 15:37

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)

查看更多
Juvenile、少年°
3楼-- · 2019-06-24 15:38

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.

查看更多
祖国的老花朵
4楼-- · 2019-06-24 15:43

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

查看更多
做自己的国王
5楼-- · 2019-06-24 15:51

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.

查看更多
淡お忘
6楼-- · 2019-06-24 15:55

For windows the below too works:

dataDir=C:\\zookeeper-3.4.14\\zookeeper-3.4.14\\data
查看更多
Summer. ? 凉城
7楼-- · 2019-06-24 15:56

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.

查看更多
登录 后发表回答