测试服务器- Zookeeper安装手记
1.解压zookeeper-3.4.6.tar.gz到重命名到/opt/bigdata/zookeeper下
2.创建文件夹
#进入到Zookeeper安装目录执行
mkdir data
mkdir log
3.进入到conf中复制并修改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=/opt/bigdata/zookeeper/data
dataLogDir=/opt/bigdata/zookeeper/log
# 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=m1:2888:3888
server.2=m2:2888:3888
server.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,v4
scp_many ./zookeeper/ $PWD m2,m3
6.执行zkServer.sh start然后在status看状态就好了。
批量scp脚本:
#!/bin/bash
# description: scp file to many hosts
filename=$1
targetname=$2
hosts=$3
if [ $# -lt 3 ];then
echo -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 1
fi
#for host in $(echo $3|awk -F,)
for host in ${hosts//,/ }
do
cmd="scp -r $filename $host:$targetname"
echo -e "$\033[46;37m$cmd\033[0m"
$cmd
done