[Zookeeper] Setting up the Cluster

Recently has to setup a Zookeeper cluster. Its very easy to setup a cluster, though documentation make you think a bit.

In this post shall attempt to list the steps I performed.

Note: Have performed the steps against the Zookeeper 3.4.5 release.

The process of setting up a Zookeeper cluster

  • Downloading Zookeeper release on all the machines
  • Adding id file
  • Updating zoo.cfg in Zookeeper installation

Step 1: Dowloading Zookeeper binary

Download Zookeeper binary on all the machines on which you want to install the Zookeeper nodes and untar them

Step 2: Adding the id file

For each Zookeeper install create a file myid in the data dir. The data directory can be located from zoo.cfg file. It’s the directory pointed by dataDir variable in zoo.cfg.
myid gives the Zookeeper node an id. Zookeeper shall look here to find out its id and resolve related configuration in zoo.cfg.
The id must be unique for each Server in the Cluster.

myid would like something like this


Step 3: Updating zoo.cfg

Now the last step of configuring the zoo.cfg. Need to add the following snippet in zoo.cfg on all Zookeeper installations

#Cluster configuration assuming 3 nodes

Here is where the Zookeeper would use to find its configuration. It would use the id from myid file and resolve the configuration.

Now start the Servers.

Verifying the installations

On each node, invoke the following command (from Zookeeper bin directory)

$zkServer.sh status

You shall see something like “Mode: leader” or “Mode: follower”

That’s it. Happy Clustering

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.