一.下載
1.wget http://apache.fayea.com/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
2. tar -zxvf zookeeper-3.4.10.tar.gz
二.配置
1.cd zookeeper-3.4.10/conf/
2.複製 zoo_sample.cfg 文件的並命名爲爲 zoo.cfg:
cp zoo_sample.cfg zoo.cfg
3.用 vim 打開 zoo.cfg 文件並修改其內容爲如下:
# The number of milliseconds of each tick
# zookeeper 定義的基準時間間隔,單位:毫秒
tickTime=2000
時長單位爲毫秒,爲zk使用的基本時間度量單位。例如,1 * tickTime是客戶端與zk服務端的心跳時間,2 * tickTime是客戶端會話的超時時間。
tickTime的默認值爲2000毫秒,更低的tickTime值可以更快地發現超時問題,但也會導致更高的網絡流量(心跳消息)和更高的CPU使用率(會話的跟蹤處理)。
# 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
# 數據文件夾
dataDir=/usr/local/services/zookeeper/zookeeper-3.4.10/data
# 日誌文件夾
dataLogDir=/usr/local/services/zookeeper/zookeeper-3.4.10/logs
# the port at which the clients will connect
# 客戶端訪問 zookeeper 的端口號
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
server.1=192.168.80.128:2888:3888
4.用 vim 打開 /etc/ 目錄下的配置文件 profile:
vim /etc/profile
並在其尾部追加如下內容:
# idea - zookeeper-3.4.10 config start
export ZOOKEEPER_HOME=/usr/local/services/zookeeper/zookeeper-3.4.10/
export PATH= PATH=$HADOOP_HOME/bin:$ZOOKEEPER_HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
11、使 /etc/ 目錄下的 profile 文件即可生效:
source /etc/profile
三.啓動
1.進入到 /usr/local/services/zookeeper/zookeeper-3.4.10/bin 目錄中:
cd ../bin/
2.sh zkServer.sh start
3.進入bin目錄,執行sh zkServer.sh status
4.關閉 進入bin目錄,執行sh zkServer.sh stop
四.telnet 連接
telnet 192.168.80.128 2128
stat