Summary

1. Introduction

2. Architecture

3. Zookeeper Setup

4. Launch and Shutdown Zookeeper Cluster Service

5. Verify the Zookeeper cluster is up and healthy


1. Introduction

This post is to basically guide you to setup a Zookeeper cluster based on the Hadoop cluster I previously built, please refer to my another post – Hadoop Cluster 2.6.5 Installation on CentOS 7 in basic version.

2. Architecture

IP Address Hostname Role
192.168.171.132 master NameNode, ResourceManager, QuorumPeerMain
192.168.171.133 slave1 SecondaryNameNode, DataNode, NodeManager, QuorumPeerMain
192.168.171.134 slave2 DataNode, NodeManager, QuorumPeerMain


3. Zookeeper Setup

P.S. Please login as hadoop to build this cluster.

3.1. Download and untar

wget http://apache.mirrors.pair.com/zookeeper/stable/zookeeper-3.4.9.tar.gz
tar -zxvf zookeeper-3.4.9.tar.gz
rm zookeeper-3.4.9.tar.gz

3.2. Configuration files

  • Append following content in ~/.bashrc
export ZOOKEEPER_HOME=/home/hadoop/zookeeper-3.4.9
export PATH=$PATH:$ZOOKEEPER_HOME/bin
  • Make environment variable valid
source ~/.bashrc
  • Create zoo.cfg file
cp $ZOOKEEPER_HOME/conf/zoo_sample.cfg $ZOOKEEPER_HOME/conf/zoo.cfg
  • Append the following to zoo.cfg
dataLogDir=/home/hadoop/zookeeper-3.4.9/logs

server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888

3.3. Copy the zookeeper folder and configuration to all nodes

cd ~
scp -r .bashrc slave1:~/
scp -r .bashrc slave2:~/

scp -r zookeeper-3.4.9 slave1:~/
scp -r zookeeper-3.4.9 slave2:~/

3.4. Specify the server id according to the zoo.cfg configuration, around all nodes

ssh master echo 1 > $ZOOKEEPER_HOME/data/myid
ssh slave1 echo 2 > $ZOOKEEPER_HOME/data/myid
ssh slave2 echo 3 > $ZOOKEEPER_HOME/data/myid

P.S. 1 for master, 2 for slave1, 3 for slave2

4. Launch and Shutdown Zookeeper Cluster Service

zkServer.sh start
zkServer.sh stop

5. Verify the Zookeeper cluster is up and healthy

  • use jps to check through all nodes
# jps
29765 QuorumPeerMain
  • zkCli.sh to verify all nodes are well being synchronized.

  • Done.