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 命令 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM