Pre-requisites

Before starting with Zookeeper cluster mode installation, make sure that the node have the following pre-requisites:

a)  Supported Platforms: GNU/Linux, Win32, MacOSX, FreeBSD and Sun Solaris. This blog describes the installation steps for Linux.
b)  Sun Java 1.6 or above should already be installed. To install Java, you can refer to the installation steps mentioned in the blog.
c)  All the nodes are part of an ensemble and it is advisable to have odd number of nodes in an ensemble. The Zookeeper service is available, only if majority of the zookeeper servers in an ensemble are running.

Zookeeper Clustered Mode Installation Steps

Follow the steps mentioned below for Zookeeper Clustered Mode Installation:

1. Download the zookeeper tar from here.
2. Use sudo option and move the tar file to any system directory like /opt. If you don’t have the permission to access to any system directory, then you can use your home directory for Zookeeper installation (/home/). Assuming the Zookeeper version to be 3.4.6, the command will look like:

mv zookeeper-3.4.6.tar.gz /opt

3. Extract the contents of the tar file.

tar -xzvf zookeeper-3.4.6.tar.gz
cd /opt/zookeeper-3.4.6

4. Create a zoo.cfg file in conf folder:

nano /opt/zookeeper-3.4.6/conf/zoo.cfg

5. Add following in the file:

tickTime=2000
dataDir=/opt/zookeeperdata
clientPort=2181
initLimit=5
syncLimit=2
server.1=192.168.56.101:2888:3888
server.2=192.168.56.102:2888:3888
server.3=192.168.56.103:2888:3888

tickTime: The time in millisecond used by zookeeper for heartbeats and session management. Minimum session timeout would be double the ticktime.
dataDir: The directory to store zookeeper data. It stores in-memory data snapshots and transaction logs of data updates.
clientPort: The port to be used for client connections.
initLimit: The max time duration used by the zookeeper server in the quorum to connect to the leader.
syncLimit: The max time for a server to be outdated from a leader.
server.x : It is the list of servers that made up the zookeeper service. There are three values for a server: a hostname / IP Address of server, a port used by followers to connect to the leader and a port used by servers during the leader election.

6. Create a file in /opt/zookeeperdata with name myid and just add the server number in the file. The server id’s must be unique for all the Zookeeper servers in the ensemble. Its value should be between 1 and 255.
For Ex. In node with IP 192.168.56.101, corresponding server name is server.1. So just add 1 in the file myid created in /opt/zeekeeperdata.

7. Copy the zookeeper folder on all nodes that are going to be the part of emsemble.

bin/zkServer.sh start

8. Change myid for each node with the server id of that node.

9. Start zookeeper on each node using:

bin/zkServer.sh start

10. Check for the service “QuorumPeerMain” running for ZooKeeper using jps command.

ZooSnap

Share this:

Leave a Reply

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