zookeeper自动化安装配置脚本

#!/bin/bash

#/usr/local/zookeeper1/bin/zkServer.sh start 
#/usr/local/zookeeper2/bin/zkServer.sh start 
#/usr/local/zookeeper3/bin/zkServer.sh start

setup_dir="/usr/local/"
zooVersion="zookeeper-3.4.8"

cd $setup_dir
wget http://apache.fayea.com/zookeeper/${zooVersion}/${zooVersion}.tar.gz || wwwget http://apache.fayea.com/zookeeper/${zooVersion}/${zooVersion}.tar.gz
tar zxvf ${zooVersion}.tar.gz
mkdir -p ${zooVersion}/data

cp -a ${zooVersion}  zookeeper1
cp -a ${zooVersion}  zookeeper2
cp -a ${zooVersion}  zookeeper3

z1="${setup_dir}zookeeper1/"
z2="${setup_dir}zookeeper2/"
z3="${setup_dir}zookeeper3/"

#########################################################################

cat >>${z1}conf/zoo.cfg << eof
# 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.
# example sakes.
dataDir=${z1}data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
#autopurge.purgeInterval=1
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890
eof

##########################################################################
cat >>${z2}conf/zoo.cfg << eof
# 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.
# example sakes.
dataDir=${z2}data
# the port at which the clients will connect
clientPort=2182
# the maximum number of client connections.
#autopurge.purgeInterval=1
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890
eof
##########################################################################

cat >>${z3}conf/zoo.cfg << eof
# 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.
# example sakes.
dataDir=${z3}data
# the port at which the clients will connect
clientPort=2183
# the maximum number of client connections.
#autopurge.purgeInterval=1
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890
eof

# dataDir新建myid文件写入数字表示这是第几号server. 该数字必须和zoo.cfg文件中的server.X中的X对应
echo 1 >${z1}data/myid
echo 2 >${z2}data/myid
echo 3 >${z3}data/myid

echo "# Zookeeper" >>/etc/rc.local
echo "${z1}bin/zkServer.sh start" >>/etc/rc.local
echo "${z2}bin/zkServer.sh start" >>/etc/rc.local
echo "${z3}bin/zkServer.sh start" >>/etc/rc.local

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

厉力文武

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值