Window下zookeeper安装和启动

请参考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 命令 

posted on 2020-04-15 18:39  dreamstar  阅读(3401)  评论(0编辑  收藏  举报