zookeeper安裝與配置

【轉載請註明做者和原文連接,歡迎討論,相互學習。】html

 

1、環境
1.操做系統:centos 6
2.3臺虛擬機,192.168.1.128,192.168.1.129,192.168.1.130
3.關閉防火牆apache

2、安裝與配置步驟
1.下載zookeeper,如:zookeeper-3.4.6.tar.gz,放到/usr/local目錄下,並解壓
   cd /usr/local/centos

   tar zxvf zookeeper-3.4.6.tar.gz ide

2.目錄修改成zookeeper
mv zookeeper-3.4.6 zookeeper

3.在/usr/local/zookeeper目錄下,新建日誌目錄和日誌目錄
mkdir /usr/local/zookeeper/data
mkdir /usr/local/zookeeper/logs

4.配置文件修改與配置參數說明
4.1 配置修改
將/usr/local/zookeeper/conf下的zoo_sample.cfg重命名爲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=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/logs
# 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
server.1=192.168.1.128:2888:3888
server.2=192.168.1.129:2888:3888
server.3=192.168.1.130:2888:3888

4.2 配置參數說明
initLimit:zookeeper集羣包含一臺leader和多臺follower,initLimit表示初始化鏈接時,follower和leader之間最長的心跳時間。
syncLimit:follower和leader之間發送消息,請求與應答的最大時間,即5x2000ms=10000ms=10s。
server.X=A:B:C 其中X是一個數字,表示第幾號server,A是IP或者域名,B是該server和集羣leader交換信息所用端口號,C是選擇leader時所用端口號。

5.在/usr/local/zookeeper/data目錄下,新建文件myid,
touch /usr/local/zookeeper/data/myid
對於192.168.1.128,myid文件內容爲1,
對於192.168.1.129,myid文件內容爲2,
對於192.168.1.130,myid文件內容爲3學習

3、啓動與關閉
啓動:/usr/local/zookeeper/bin/zkServer.sh start
關閉:/usr/local/zookeeper/bin/zkServer.sh stop
重啓:/usr/local/zookeeper/bin/zkServer.sh restart
查看:/usr/local/zookeeper/bin/zkServer.sh statusui

相關文章
相關標籤/搜索