(三)ZooKeeper下載、安裝及配置

一、下載

官網(wǎng)下載鏈接:https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz

二、安裝

這里我是在本地(mac)安裝滴,也可以在服務(wù)器安裝,隨你啦。
在本地解壓至/Users/用戶名/app:

tar -zxvf zookeeper-3.4.6.tar.gz -C /Users/huluwa/app

將解壓后的文件夾改名:

mv zookeeper-3.4.6/ zookeeper

三、配置(要運行zk就需要此配置)

在安裝路徑:/Users/huluwa/app/zookeeper/conf中 新建 配置文件zoo.cfg

最好是拷貝格式來新建:

cp zoo_sample.cfg zoo.cfg

conf中的zoo_sample.cfg是默認(rèn)的配置文件(以cfg結(jié)尾),如果用戶沒有新建cfg配置文件,就使用默認(rèn)的。

now,先新建一個文件夾用于配置中的dataDir路徑配置。

vim ~/data   #路徑為 /Users/huluwa/data

接著配置zoo.cfg(主要是配置dataDir):

# 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=/root/data/zookeeper
dataDir=/Users/huluwa/data      #其實主要是配置這個參數(shù)啦啦啦
# 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

四、配置環(huán)境變量

這步可配也可以不配置。配置了就能在全局執(zhí)行zk的命令了,不然只能進入zk 的安裝路徑下執(zhí)行一些命令。

五、啟動服務(wù)

進入zk安裝路徑

cd ~/app/zookeeper/
cd bin/
ls


zkCli.sh 客戶端執(zhí)行文件, zkServer.sh 服務(wù)端執(zhí)行文件
ok,let's 啟動客戶端服務(wù):

./zkServer.sh start

omg! 出現(xiàn)了權(quán)限錯誤:



那我們給這個文件夾賦全部的權(quán)限吧!

chmod -R 777 /Users/huluwa/data/zookeeper  #777是全部的權(quán)限

ok,再一次啟動服務(wù)端服務(wù):

./zkServer.sh start

六、查看zookeeper運行及狀態(tài)

安裝后,可以看到zookeeper提供了zkCli等工具。
同樣,在bin目錄下,執(zhí)行:

./zkCli.sh 
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容