1、文件解压安装
[centos@hadoop10 data]$ tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz -C /data/module
[centos@hadoop10 module]$ mv apache-zookeeper-3.5.7-bin/ /data/module/zookeeper
[centos@hadoop10 zookeeper]$ mkdir zkData
2、服务器表示设置
[centos@hadoop10 zkData]$ vim myid
设置成0、1、2 区分每个服务器
3、配置文件配置
[centos@hadoop10 conf]$ mv zoo_sample.cfg zoo.cfg
[centos@hadoop10 conf]$ vim 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=/data/module/zookeeper/zkData
# 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.0=hadoop10:2888:3888
server.1=hadoop11:2888:3888
server.2=hadoop12:2888:3888
4、批量分发
xsync zookeeper/
更改zkData/myid
5、启动脚本
[centos@hadoop10 data]$ /data/module/zookeeper/bin/zkServer.sh start
6、批量启动脚本
zk.sh
#!/bin/bash
case $1 in
"start"){
for i in hadoop10 hadoop11 hadoop12
do
echo ---------- zookeeper $i 启动 ------------
ssh $i "/data/module/zookeeper/bin/zkServer.sh start"
done
};;
"stop"){
for i in hadoop10 hadoop11 hadoop12
do
echo ---------- zookeeper $i 停止 ------------
ssh $i "/data/module/zookeeper/bin/zkServer.sh stop"
done
};;
"status"){
for i in hadoop10 hadoop11 hadoop12
do
echo ---------- zookeeper $i 状态 ------------
ssh $i "/data/module/zookeeper/bin/zkServer.sh status"
done
};;
esac