ZooKeeper Single Server


Pre Requirements

1) A machine with Ubuntu 14.04 LTS operating system

2) Apache Hadoop 2.6.4 pre installed

3) Apache ZooKeeper 3.4.6 software (Download Here)

ZooKeeper 3.4.6 Single Server setup on Ubuntu

Installation Steps

Step 1 - Update. Open a terminal (CTRL + ALT + T) and type the following sudo command. It is advisable to run this before installing any package, and necessary to run it to install the latest updates, even if you have not added or removed any Software Sources.




$ sudo apt-get update

Step 2 - Installing Java 7.




$ sudo apt-get install openjdk-7-jdk

Step 3 - Edit $HOME/.bashrc file by adding the java path.




$ sudo gedit $HOME/.bashrc

$HOME/.bashrc file. Add the following lines




export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

Step 4 - Reload your changed $HOME/.bashrc settings




$ source $HOME/.bashrc

Step 5 - Creating zookeeper directory.




$ sudo mkdir /usr/local/zookeeper

Step 6 - Change the ownership and permissions of the directory /usr/local/zookeeper. Here 'hduser' is an Ubuntu username.




$ sudo chown -R hduser /usr/local/zookeeper
$ sudo chmod -R 755 /usr/local/zookeeper

Step 7 - Creating /zookeeper/data directory.




$ sudo mkdir /usr/local/zookeeper/data

Step 8 - Change the ownership and permissions of the directory /usr/local/zookeeper/data. Here 'hduser' is an Ubuntu username.




$ sudo chown -R hduser /usr/local/zookeeper/data
$ sudo chmod -R 755 /usr/local/zookeeper/data

Step 9 - Creating /zookeeper/log directory.




$ sudo mkdir /usr/local/zookeeper/log

Step 10 - Change the ownership and permissions of the directory /usr/local/zookeeper/log. Here 'hduser' is an Ubuntu username.




$ sudo chown -R hduser /usr/local/zookeeper/log
$ sudo chmod -R 755 /usr/local/zookeeper/log

Step 11 - Change the directory to /home/hduser/Desktop , In my case the downloaded zookeeper-3.4.6.tar.gz file is in /home/hduser/Desktop folder. For you it might be in /downloads folder check it.




$ cd /home/hduser/Desktop/

Step 12 - Untar the zookeeper-3.4.6.tar.gz file.




$ tar xzf zookeeper-3.4.6.tar.gz

Step 13 - Move the contents of zookeeper-3.4.6 folder to /usr/local/zookeeper




$ mv zookeeper-3.4.6/* /usr/local/zookeeper

Step 14 - Change the directory to /usr/local/zookeeper/conf




$ cd /usr/local/zookeeper/conf

Step 15 - Edit zoo.cfg file. If this file doesn't exists it will create one for you and it ll open for you to edit.




$ gedit zoo.cfg

Step 16 - Add following lines to zoo.cfg file. Save and close.




tickTime=2000
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/log
clientPort=2181
initLimit=5
syncLimit=2


Step 17 - Change the directory to /usr/local/zookeeper/bin




$ cd /usr/local/zookeeper/bin

Step 18 - Start zookeeper server




$ ./zkServer.sh start

Step 19 - Start client




$ ./zkCli.sh -server 127.0.0.1:2181

<


Step 20 - Stop zookeeper server




$ ./zkServer.sh stop



Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *