Friday, November 4, 2016

Building Apache Zookeeper Ensemble

Zookeeper ensemble

Create a default RHEL EC2 instance

sudo lsblk
sudo file -s /dev/xvdb
sudo mkfs -t ext4 /dev/xvdb
sudo mkdir -p /apps/zookeeper
sudo mount /dev/xvdb /apps/zookeeper
sudo useradd zookeeper
sudo chown -R zookeeper:zookeeper /apps/zookeeper
sudo vi /etc/fstab
/dev/xvdb  /apps/zookeper  ext4    defaults,nofail        0       2
sudo su - zookeeper

download jdk1.8.0_102
download zookeeper-3.4.9

setup ~/.bash_profile

FS_ROOT=/apps/zookeeper
JAVA_HOME=$FS_ROOT/jdk1.8.0_102
ZOOKEEPER_HOME=$FS_ROOT/zookeeper-3.4.9
SCRIPTS=$FS_ROOT/scripts
PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH
export PATH JAVA_HOME ZOOKEEPER_HOME SCRIPTS

mkdir /apps/zookeeper/data
mkdir /apps/zookeeper/dataLog
mkdir /apps/zookeeper/logs

Create a file zoo.cfg with 
tickTime=2000
dataDir=/apps/zookeeper/data
dataLogDir=/apps/zookeeper/dataLog
clientPort=2181
initLimit=5
syncLimit=2
server.1=zoo1:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888

Create a file myid in /apps/zookeeper/data directory with '1' as content

Update AWS EC2 sec group with ports 22 2181 2888 3888

Create an AMI and spin 2 more instances
update myid file on server2 as 2 and server3 as 3

update zoo.cfg server ips  on all servers

create a start script  start_zookeeper.sh

source ~/.bash_profile
cd $ZOOKEEPER_HOME/bin
./zkServer.sh start

or
nohup java -cp zookeeper-3.4.9.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-log4j12-1.6.1.jar:lib/log4j-1.2.16.jar:conf org.apache.zookeeper.server.quorum.QuorumPeerMain $SCRIPTS/zoo.cfg  > $FS_ROOT/logs/zookeeper.log 2>&1 &

Some known issues
If the port 3888 is not listening, check myid file in data folder has correct id



No comments:

Post a Comment