1.選擇zookeeper文件夾
安裝的時候選擇的是/usr/local目錄,根據個人情況而定
2.下載zookeeper文件壓縮包
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
3.解壓壓縮包到當前目錄
tar -zxvf zookeeper-3.4.9.tar.gz
4.重命名目錄文件(可以不改)
mv zookeeper-3.4.9\ zookeeper
5.復制zookeeper配置文件並重命名zoo.cfg
cd zookeeper/conf/
cp zoo_sample.cfg zoo.cfg
6.修改zoo.cfg文件
vim zoo.cfg
# The number of milliseconds of each tick
# zookeeper 定義的基准時間間隔,單位:毫秒
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=/tmp/zookeeper
# 數據文件夾
dataDir=/usr/local/zookeeper/data
# 日志文件夾
dataLogDir=/usr/local/zookeeper/logs
# the port at which the clients will connect
# 客戶端訪問 zookeeper 的端口號
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
:wq保存退出
7.增加zookeeper環境變量
#修改環境變量文件 vim /etc/profile #后面增加zookeeper變量 export ZOOKEEPER_INSTALL=/usr/local/zookeeper/ export PATH=$PATH:$ZOOKEEPER_INSTALL/bin export PATH
:wq保存退出
8.使環境變量生效
source /etc/profile
9.啟動zookeeper服務
cd /usr/local/bin
#啟動服務器
./skServer.sh start
10.查詢zookeeper服務
zkServer.sh status
11.查詢zookeeper進程
jps
其中QuorumPeerMain是屬於zookeeper的進程,表示zookeeper服務已經正常啟動
12.安裝過程中的出現的問題
12.1出現啟動成功,但是進程沒有啟動
./zkServer.sh start-foreground #啟動過程中加入參數詳細輸出
提示找不到class org.apache.zookeeper.server.quorum.QuorumPeerMain類方法
zookeeper啟動需要依賴java環境,將java環境添加到/etc/profile文件內
echo $JAVA_HOME
出現java版本說明java環境正常,如果還存在找不到類方法就重新下載一個zookeeper版本