Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Pre-requisites

  • OpenJDK8
  • Zookeeper

Install OpenJDK

$ sudo apt-get install openjdk-8-jdk 

...


Edit the /etc/hosts file across all the nodes and add the ipaddress and hostname (nodenames).


192.168.1.102 node1
192.168.1.103 node2
192.168.1.105 node3

Create zookeeper user

$ sudo adduser zookeeper


Configure zookeeper

Now, Create the directory zookeeper under /var/lib folder which will serve as Zookeeper data directory and create another zookeeper directory under /var/log where all the Zookeeper logs will be captured. Both of the directory ownership need to be changed as zookeeper.

$ sudo mkdir /var/lib/zookeeper

$ cd /var/lib

$ sudo chown zookeeper:zookeeper zookeeper/

$ sudo mkdir /var/log/zookeeper ;

$ cd /var/log ;

$ sudo chown zookeeper:zookeeper zookeeper/

...

$ export ZOO_LOG_DIR=/var/log/zookeeper


Source the .bashrc in current login session:

$ source ~/.bashrc

Create the server id for the ensemble. Each zookeeper server should have a unique number in the myid file within the ensemble and should have a value between 1 and 255.

In Node1

$ sudo sh -c "echo '1' > /var/lib/zookeeper/myid"


In Node2

$ sudo sh -c "echo '2' > /var/lib/zookeeper/myid"


In Node3

$ sudo sh -c "echo '3' > /var/lib/zookeeper/myid"


Now, go to the conf folder under the Zookeeper home directory (location of the Zookeeper directory after Archive has been unzipped/extracted).

$ cd /home/zookeeper/zookeeper-3.4.13/conf/

By default, a sample conf file with name zoo_sample.cfg will be present in conf directory. Make a copy of it with name zoo.cfg as shown below, and edit new zoo.cfg as described across all the nodes.

$ cp zoo_sample.cfg zoo.cfg


Edit zoo.cfg and the below

$ vim /home/zookeeper/zookeeper-3.4.13/conf/zoo.cfg


dataDir=/var/lib/zookeeper
server.1=node1:2888:3888
server.2=node2:2888:3888
server.3=node3:2888:3888


Now, do the below changes in log4.properties file as follows.

$ vim /home/zookeeper/zookeeper-3.4.13/conf/log4j.properties


zookeeper.log.dir=/var/log/zookeeper 
zookeeper.tracelog.dir=/var/log/zookeeper 
log4j.rootLogger=INFO, CONSOLE, ROLLINGFILE


After the configuration has been done in zoo.cfg file in all three nodes, start zookeeper in all the nodes one by one, using following command:

$ /home/zookeeper/zookeeper-3.4.13/bin/zkServer.sh start


Zookeeper Service Start on all the Nodes.

Zookeeper Service Start on all three Nodes.Image Added


The log file will be created in /var/log/zookeeper of zookeeper named zookeeper.log, tail the file to see logs for any errors.

$ tail -f /var/log/zookeeper/zookeeper.log