windows环境下安装Zookeper

刚学习Zookeper时大多数都是直接在windows环境下安装,本文主要介绍Zookeper安装启动及注意事项,由于Zookeper需要在java环境运行,启动之前配置好java环境变量
1.下载Zookeper
链接:https://pan.baidu.com/s/1tsU3-FI0_k48e9dBY0TDmQ
提取码:t2nn
2.解压文件到本地,一下为Zookeper文件目录
windows环境下安装Zookeper_第1张图片
3.创建data、log两个文件夹用于存储数据与日志信息
windows环境下安装Zookeper_第2张图片
4.进入conf文件复制zoo_sample.cfg并命名为zoo.cfg
windows环境下安装Zookeper_第3张图片
5.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=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# 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

6 编辑配置信息,修改dataDir的值,指向刚才创建的data文件夹,同时创建一个dataLogDir,指向上一次创建的log文件夹,修改后为

# 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/development/zookeeper-3.4.12/zookeeper-3.4.12/data 
dataLogDir=D:/development/zookeeper-3.4.12/zookeeper-3.4.12/log
#####################################################
# the port at which the clients will connect
clientPort=2181
# 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

两次对比
windows环境下安装Zookeper_第4张图片

windows环境下安装Zookeper_第5张图片
7.进入Zookeper主目录下打开bin目录,会看到以下文件
windows环境下安装Zookeper_第6张图片
zkServer.cmd为windows环境下服务端启动命令
编辑zkServer.cmd,需要修改启动命令,下面为启动脚本,直接启动DOS会直接闪退,因为这个脚本需要做一些修改
windows环境下安装Zookeper_第7张图片
a)在结尾之前需要指定Zookeper配置文件路径,我的路径配置如下,只需要将路径改为对应的zoo.cfg路径

set ZOOCFG=D:/development/zookeeper-3.4.12/zookeeper-3.4.12/conf/zoo.cfg

windows环境下安装Zookeper_第8张图片

b)启动依然报错,添加一个暂停,启动zkServer.cmd查看错误信息
windows环境下安装Zookeper_第9张图片
windows环境下安装Zookeper_第10张图片
日志提示是因为Zookeper需要在环境变量中配置JAVA变量,可能很多人直接将path中添加的环境,这样 call ‘%jJAVA%’ 找不到对应的变量值,直接将call "%JAVA%"改成java,直接执行java命令,这样只要配置了java环境变量就可使用

windows环境下安装Zookeper_第11张图片
windows环境下安装Zookeper_第12张图片

执行server启动脚本,出现以下画面,则Zookeper启动完成
windows环境下安装Zookeper_第13张图片
8.启动客户端,若出现闪退,修改脚本

windows环境下安装Zookeper_第14张图片
9.启动客户端,Zookeper安装启动完成
windows环境下安装Zookeper_第15张图片

你可能感兴趣的:(java,java,zookeeper)