安裝 zookeeper 之前需要先安裝 jdk,關於 jdk 的安裝見 jdk安裝
解壓
tar -zxvf zookeeper-3.4.8.tar.gz
目錄重新命名
mv zookeeper-3.4.8 zookeeper
修改使用者和使用者組
chown —r hadoop:hadoop zookeeper/
配置環境變數
## 編輯.bashrc檔案,在檔案末尾新增以下環境變數配置:
# zookeeper env
export zookeeper_home=/opt/zookeeper
export path=$path:$zookeeper_home/bin
## 使環境變數生效
source .bashrc
初次使用 zookeeper 時, 需要將$zookeeper_home/conf
目錄下的zoo_sample.cfg
重新命名為zoo.cfg
,zoo.cfg
預設配置如下:
# the number of milliseconds of each
tickticktime=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
# 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.
## ## 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 的部署模式有 3 種:- 單機模式
- 偽集群模式
- 集群模式
zoo.cfg
配置
引數說明:ticktime=2000
clientport=2181
至此, zookeeper的單機模式已經配置好了。
啟動server只需執行指令碼:
bin/zkserver.sh start
server 啟動之後,就可以啟動 client 連線 server 了,執行指令碼:
bin/zkcli.sh -server localhost:2181
所謂偽集群, 是指在單台機器中啟動多個zookeeper程序, 並組成乙個集群. 以啟動3個zookeeper程序為例。
將zookeeper的目錄拷貝2份:
更改|--zookeeper0
|--zookeeper1
|--zookeeper2
zookeeper0/conf/zoo.cfg
檔案為:
新增幾個引數,其含義如下:ticktime=2000
initlimit=5
synclimit=2
clientport=2181
server.0=127.0.0.1:8880:7770
server.1=127.0.0.1:8881:7771
server.2=127.0.0.1:8882:7772
參照zookeeper0/conf/zoo.cfg
,配置zookeeper1/conf/zoo.cfg
和zookeeper2/conf/zoo.cfg
檔案。只需更改datadir、datalogdir、clientport 引數即可。
在之前設定的 datadir 中新建myid
任意選擇乙個server目錄,啟動客戶端:
bin/zkcli.sh -server localhost:4180
集群模式的配置和偽集群基本一致。
由於集群模式下,各 server 部署在不同的機器上,因此各 server 的conf/zoo.cfg
檔案可以完全一樣。
示例中部署了 3 臺 zookeeper server,分別部署在ticktime=2000
initlimit=5
synclimit=2
datadir=/home/zookeeper/data
datalogdir=/home/zookeeper/logs
clientport=2181
server.48=192.168.186.48:2888:3888
server.49=192.168.186.49:2888:3888
server.50=192.168.186.50:2888:3888
192.168.186.48
、192.168.186.49
、192.168.186.50
上。需要注意的是各 server 的 datadir 目錄下的 myid 檔案中的數字必須不同,如下:
本文由部落格一文多發平台 openwrite 發布!
zookeeper 安裝部署
2.解壓 tar zxvf zookeeper 3.5.1.tar.gz 3.將zookeeper 3.5.1 conf 目錄下的zoo sample.cfg修改為zoo.cfg,配置如下 ticktime 2000 datadir home zookeeper data clientport 21...
Zookeeper安裝部署
zookeeper zookeeper是乙個分布式協調服務的開源框架。主要用來解決分布式集群中應用系統的一致性問題。zookeeper本質上是乙個分布式的小檔案儲存系統。提供基於類似於檔案系統的目錄樹方式的資料儲存,並且可以對樹中的節點進行有效管理。從而用來維護和監控你儲存的資料的狀態變化。通過監控...
zookeeper安裝部署
計畫zookeeper的安裝目錄為 home dmp zookeeper 2.上傳安裝包到臨時目錄 home python root data2 python ls lrt rw r r 1 root root 12392394 8月 19 22 43 apache zookeeper 3.6.0 ...