Windows 系统下载安装 ZooKeeper教程
Windows 系统下载安装 ZooKeeper
=============================================
这里演示 Apache ZooKeeper 3.4.14 版本的下载与安装
进入官网下载 ZooKeeper
ZooKeeper 官网地址: https://zookeeper.apache.org/
点击上面官网链接进入官网
跳转页面后,点击下载
Zookeeper 安装
- 下载完后直接解压,解压后目录如下:
- 创建一个 data 文件夹和 log 文件夹
- 进入 config 文件夹,将 zoo\_sample.cfg 复制一份,并重命名 zoo.cfg
- 修改 zoo.cfg 内的配置信息
dataDir 和 dataLogDir 根据自己的真实路径填写。就是我们刚刚创建的 data 和 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:\\Code\\tool\\java\\zookeeper-3.4.14\\zookeeper-3.4.14\\data
dataLogDir=D:\\Code\\tool\\java\\zookeeper-3.4.14\\zookeeper-3.4.14\\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
运行 ZooKeeper
- 进入 bin 目录,启动 zkServer.cmd
如果闪退的话,就代表启动失败,可能是我们刚刚配置错误了。
编辑 zkServer.cmd 文件,增加 @pause 让它报错时停下来,然后根据报错百度查询解决方案。
java.io.IOException: Unable to create data directory XXX 代表是文件路径错误了,检查 dataDir 和 dataLogDir 的路径
@echo off
REM Licensed to the Apache Software Foundation (ASF) under one or more
REM contributor license agreements. See the NOTICE file distributed with
REM this work for additional information regarding copyright ownership.
REM The ASF licenses this file to You under the Apache License, Version 2.0
REM (the "License"); you may not use this file except in compliance with
REM the License. You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.
setlocal
call "%~dp0zkEnv.cmd"
set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
echo on
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*
@pause
endlocal
- 运行成功