1. 程式人生 > >zookeeper單機安裝

zookeeper單機安裝

1.下載zookeeper:

wget http://apache.fayea.com/zookeeper/stable/zookeeper-3.4.6.tar.gz

2.解壓

tar zxvf zookeeper-3.4.6.tar.gz

3.配置

進入配置資料夾,將zoo_sample.cfd檔名稱改為zoo.cfg, 預設的配置內容如下

# 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=/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. # # 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

配置說明:

tickTime:這個時間是作為 Zookeeper 伺服器之間或客戶端與伺服器之間維持心跳的時間間隔,也就是每個 tickTime 時間就會發送一個心跳。

dataDir:顧名思義就是 Zookeeper 儲存資料的目錄,預設情況下,Zookeeper 將寫資料的日誌檔案也儲存在這個目錄裡。

dataLogDir: log目錄, 同樣可以是任意目錄. 如果沒有設定該引數, 將使用和dataDir相同的設定。

clientPort:這個埠就是客戶端連線 Zookeeper 伺服器的埠,Zookeeper 會監聽這個埠,接受客戶端的訪問請求。

4、啟動Zookeeper

當這些配置項配置好後,你現在就可以啟動zookeeper了:

./zkServer.sh start #啟動
netstat -tunlp|grep 2181 #檢視zookeeper埠
./zkServer.sh stop #停止