测试服务器- Zookeeper安装手记
1.解压zookeeper-3.4.6.tar.gz到重命名到/opt/bigdata/zookeeper下
2.创建文件夹
#进入到Zookeeper安装目录执行mkdir datamkdir log
3.进入到conf中复制并修改zoo.cfg文件
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial# synchronization phase can takeinitLimit=10# The number of ticks that can pass between# sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just# example sakes.dataDir=/opt/bigdata/zookeeper/datadataLogDir=/opt/bigdata/zookeeper/log# the port at which the clients will connectclientPort=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=1server.1=m1:2888:3888server.2=m2:2888:3888server.3=m3:2888:3888
4.添加zk节点的myid,在data文件夹中
#这个id 在别的机器上需要修改,根据zoo.cfg中声明的填写echo 1 > /opt/bigdata/zookeeper/conf/myid
5.分发整个文件夹到别的节点
cd /opt/bigdata/#下面这个是我写的批量scp脚本#语法是:#Usage: /usr/bin/scp_many filename targetname host[s]#e.g: /usr/bin/scp_many love.txt /home/love.txt v2,v3,v4scp_many ./zookeeper/ $PWD m2,m3
6.执行zkServer.sh start然后在status看状态就好了。
批量scp脚本:
#!/bin/bash# description: scp file to many hostsfilename=$1targetname=$2hosts=$3if [ $# -lt 3 ];thenecho -e "Usage:\033[45;37m $0 filename targetname host[s] \033[0m"echo -e "e.g:\033[45;37m $0 love.txt /home/love.txt v2,v3,v4\033[0m"exit 1fi#for host in $(echo $3|awk -F,)for host in ${hosts//,/ }docmd="scp -r $filename $host:$targetname"echo -e "$\033[46;37m$cmd\033[0m"$cmddone