Skip to content

Instantly share code, notes, and snippets.

@sundy-li
Created May 19, 2017 07:06
Show Gist options
  • Save sundy-li/149f7f32b74e42f343e641af69bab8ef to your computer and use it in GitHub Desktop.
Save sundy-li/149f7f32b74e42f343e641af69bab8ef to your computer and use it in GitHub Desktop.
install_zk_cluster
#!/bin/bash --login
## install zookeeper from url
#env
id=$1
hosts=("server.1=lp2:2888:3888" "server.2=lp3:2888:3888" "server.3=lp4:2888:3888")
version=3.4.10
dir="/data/local"
#script
cd $dir
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-${version}/zookeeper-${version}.tar.gz
tar -xzvf zookeeper-${version}.tar.gz
cd zookeeper-${version}
##modify config
mkdir -p /data/db/zookeeper
echo $id > /data/db/zookeeper/myid
cp conf/zoo_sample.cfg conf/zoo.cfg
sed -i 's#/tmp/zookeeper#/data/db/zookeeper#g' conf/zoo.cfg
for h in "${hosts[@]}";do echo $h >> conf/zoo.cfg;done
#start
bin/zkServer.sh start
#sleep
sleep 1
bin/zkServer.sh status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment