1.因爲是第一次搭建zk的集羣,過程當中遇到些問題,給本身也給遇到問題的人提供一種可能解決問題的方法。html
第一步:下載zk的最新版,我下的是3.4.9,在zk的官網,下載後解壓到/usr/localweb
tar -zxvf zookeeper-3.4.9apache
第二部:在conf 目錄下,複製zoo_sample.cfg 另起名zoo.cfg(爲何叫這個名字我也不清楚,應該是zk的程序檢測須要這個文件),配置zoo.cfgsocket
mv zoo_sample.cfg /usr/local/zookeeper-3.4.9/conf/zoo.cfgide
gedit 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
dataLogDir=/tmp/zookeeperLogs
# 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.154.129:2888:3888
server.2=192.168.154.133:2888:3888
server.3=192.168.154.132:2888:3888ui
上圖中的紅色部分是集羣須要配置的,this
用bin/zkCli.sh -server 192.168.154.129:2181 測試 輸入以下:
啓動成功。另外兩臺機器同樣。
另外,第二次重啓後,本機提示找不到主機的路由,一個是查看/etc/hosts 有沒有更改過(碰到過關機斷電引發出現.host.swf的狀況),再就是防火牆是否關閉;