今天分享一个本地搭建Zookeeper的小问题
具体过程就是我打算在本地搭个Zookeeper玩玩,研究下ACL。去官网下载了Zookeeper-3.7.2,解压,复制配置文件修改为zoo.cfg,重新指定dataDir, dataLogDir, 然后,原神...咳咳,不好意思串戏了, 启动Zookeeper, 报错如下:
我看到 Unable to access,本能以为权限出问题了。但是我想想,我特么windows admin 啊,怎么会有权限问题?
这是我原本的配置文件:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=D:\environment\tools\zookeeper-3.7.2\data
dataLogDir=D:\environment\tools\zookeeper-3.7.2\log
# the port at which the clients will connect
clientPort=2001
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
看出问题在哪里了嘛? 没错,就是路径中这个坑爹的 ""
我改成 "/" 就OK了
修改之后的配置文件如下:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=D:/environment/tools/zookeeper-3.7.2/data
dataLogDir=D:/environment/tools/zookeeper-3.7.2/log
# the port at which the clients will connect
clientPort=2001
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
启动成功!
出现这个问题的原因可能是,Zookeeper本身是通过java编写的,也是通过Java启动的,java读取配置文件反斜杠有特殊作用, 比如 \t是制表符等,所以才出现这个问题。
问题不大,但是说明还是要细心,路径中还是写"\"或者"/"更加合适。