美文网首页
Win10本地启动Zookeeper注意事项

Win10本地启动Zookeeper注意事项

作者: 赵信信官属 | 来源:发表于2021-03-15 22:00 被阅读0次

本文主要记录一下, 自己在Win10环境下启动Zookeeper遇到的几点小问题.
从官网下载ZK之后, 解压, 拷贝conf/zoo_sample.cfg文件,命名为zoo.cfg

图片.png

zoo.cfg具体内容如下(非生产环境配置,仅为了测试)

# 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:/Soft/apache-zookeeper-3.6.1-bin/data
logDir=D:/Soft/apache-zookeeper-3.6.1-bin/data/logs
# the port at which the clients will connect
clientPort=2182
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

# 将默认的8080端口改成38080(任意), 防止端口冲突
admin.serverPort=38080


server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:4888:5888
server.3=127.0.0.1:6888:7888
server.4=127.0.0.1:8888:9888

以上配置中主要关注下dataDir路径的写法问题(当然,其他的配置项也一样重要, 废话)

图片.png

如果你在zoo.cfg文件中配置dataDir目录值的时候,是通过上面截图上直接复制出来的目录值,然后拷贝到zoo.cfg里, 最后形成

图片.png

在Win系统中目录分隔符是反斜杠(\), 那么如果你通过zkServer.cmd启动的时候,会出现一闪而过(轻轻地我来了,没留下一点痕迹)

图片.png

那么如何让它不一闪而过,而是要查看下出错原因, 那么这个时候, 需要通过文本的方式,打开zkServer.cmd 并在最后一行加一个pause

图片.png

保存,再次点击执行zkServer.cmd

图片.png

报错信息如上, 可是已经创建了myid文件,咋还找不到呢, 原因就在于dataDir目录值不对.

图片.png

需要把反斜杠改成斜杠才可以, 这样ZK就可以正确的读取目录,找到myid文件

【总结】
1.当在Win系统执行.cmd文件一闪而过的时候, 编辑.cmd文件,在最下面添加一个pause指令, 再次执行.cmd文件,就可以看到错误信息了.
2.zoo.cfg文件里面的目录分隔符使用斜杠(/), 而不用使用反斜杠(\)

相关文章

网友评论

      本文标题:Win10本地启动Zookeeper注意事项

      本文链接:https://www.haomeiwen.com/subject/ymylcltx.html