1,下載ZooKeeper包
http://mirrors.hust.edu.cn/apache/zookeeper/
我這里下載的是zookeeper-3.4.13/
2,將壓縮包解壓到指定盤, 我的是在D盤, 重命名文件夾為zookeeper
3,進入zookeeper\conf\ , 將zoo_sample.cfg重命名為zoo.cfg
4,用記事本打開zoo.cfg修改為如下內(nèi)容
# 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:\\zookeeper\\data
dataLogDir=D:\\zookeeper\\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
其中
dataDir=D:\zookeeper\data
dataLogDir=D:\zookeeper\log
data存放數(shù)據(jù) log存放日志, 啟動時會自動建立
5,打開cmd

圖片.png

圖片.png
6,查看是否啟動(方式有多種)
netstat -ano|findstr "2181" 命令查看

圖片.png
客戶端查看

圖片.png
jps(有待了解此命令)

圖片.png
正常情況下會啟動成功 ,但是我的系統(tǒng)是win10 時出現(xiàn)如下錯誤
Error: JAVA_HOME is not set.
解決方法:
1,用記事本打開D:\zookeeper\bin\zkEnv.cmd
2,找到你的java jdk路勁,然后set路勁, 設(shè)置java環(huán)境變量
set JAVA=C:\Program Files\Java\jdk1.8.0_131\bin\java
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131