windows环境下安装Zookeper

本文详细介绍了如何在Windows环境下安装和启动Zookeeper,包括下载、解压、配置环境变量、设置数据与日志目录、编辑配置文件、修改启动脚本等步骤,以及解决启动过程中遇到的常见问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

两次对比
在这里插入图片描述

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

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

在这里插入图片描述

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

在这里插入图片描述
在这里插入图片描述

执行server启动脚本,出现以下画面,则Zookeper启动完成
在这里插入图片描述
8.启动客户端,若出现闪退,修改脚本

在这里插入图片描述
9.启动客户端,Zookeper安装启动完成
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值