Window下zookeeper安装和启动

本文详细介绍了在Windows上安装和启动Zookeeper的步骤,包括下载zookeeper-3.5.7版本,解压并配置环境变量,修改zoo.cfg配置文件,设置log路径和端口,调整zkEnv.cmd文件中的JAVA_HOME,最后通过zkServer.cmd启动Zookeeper并使用jps和netstat命令检查服务状态。

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

请参考ZooKeeper(三)ZooKeeper的安装、配置和启动 和 Windows安装和使用zookeeper

1.下载稳定的最新版本的zookeeper,这里下载了zookeeper-3.5.7版本    下载zookeeper

注意 apache-zookeeper-3.5.7-bin.tar.gz 才是启动zookeepr需要的,千万别下载错

2.解压缩 apache-zookeeper-3.5.7-bin.tar.gz 。在该文件夹下打开cmd命令 ,使用如下命令解压缩文件

tar -zxvf apache-zookeeper-3.7.7-bin.tar.gz

3.复制/conf 文件夹下的zoo_sample.cfg 并重命名为zoo.cfg。修改zoo.cfg文件如下(配置log路径)

添加如下两行三行 设置log文件路径并修改zookeeper的启动端口为8082,默认为8080

dataDir=C:\\zookeeper\\apache-zookeeper-3.5.7-bin\\data 
dataLogDir=C:\\zookeeper\\apache-zookeeper-3.5.7-bin\\log

admin.serverPort=8082

完整文件如下 

# 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=C:\\zookeeper\\apache-zookeeper-3.5.7-bin\\data 
dataLogDir=C:\\zookeeper\\apache-zookeeper-3.5.7-bin\\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
#change server port, 8080 by default
admin.serverPort=8082

4.修改 bin\zkEnv.cmd文件 ,配置JAVA_HOME,否则启动zookeepr会报错 参考启动zookeeper报错:JAVA_HOME is not set

添加 

set JAVA_HOME="C:\java\jdk1.8.0_212-X64" 

修改后的部分zkEnv.cmd文件如下

@REM setup java environment variables

set JAVA_HOME="C:\java\jdk1.8.0_212-X64"

if not defined JAVA_HOME (
  echo Error: JAVA_HOME is not set.
  goto :eof
)

set JAVA_HOME=%JAVA_HOME:"=%

if not exist "%JAVA_HOME%"\bin\java.exe (
  echo Error: JAVA_HOME is incorrectly set: %JAVA_HOME%
  echo Expected to find java.exe here: %JAVA_HOME%\bin\java.exe
  goto :eof
)

5.启动zookeeper,在/bin目录下打开cmd窗口,并执行命令 zkServer.cmd默认启动在8080端口

6.判断zookeeper是否启动成功

6.1 打开cmd窗口 执行jps -l -v 命令

会在窗口看到有如下输出 org.apache.zookeeper.server.quorum.QuorumPeerMain,表示zookeeper启动成功    

6.2 查看是不是有需要2181 端口
打开cmd窗口 执行 netstat -ano | findstr 2181 命令 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值