Zookeeper下載地址泡嘴,我選擇3.4.14版本
配置環(huán)境變量
解壓壓縮包到指定目錄捅儒,我選擇放在User目錄下
export ZOOKEEPER_HOME=/Users/wally/zookeeper-3.4.14
export PATH=$PATH:$ZOOKEEPER_HOME/bin
- 更新環(huán)境變量
source .bash_profile
配置Zookeeper
- 配置Zookeeper的配置文件
進(jìn)入Zookeeper的目錄缕减,找到conf子目錄挫鸽,默認(rèn)會(huì)有一個(gè)配置文件模板zoo_sample.cfg概疆,復(fù)制一份梳码,重命名為zoo.cfg板惑。
- 編輯zoo.cfg必搞,將dataDir屬性的值改為../data枫攀,就是將數(shù)據(jù)目錄配置到了Zookeeper根目錄下的data目錄括饶。
- 在Zookeeper根目錄下新建一個(gè)data目錄,作為Zookeeper的數(shù)據(jù)存放目錄来涨。
- clientPort图焰,為Zookeeper要使用的端口號(hào)
# 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=../data
# 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.sh
//啟動(dòng)
zkServer.sh start
//停止
zkServer.sh stop
//查看狀態(tài)
zkServer.sh status
使用Zookeeper的客戶端cli連接Zookeeper
zkCli.sh -server localhost