Setting up a ZooKeeper Quorum on Amazon EC2 with Exhibitor

Hi in this post i will try to explain step by step how to set up a ZooKeeper Quorum in Amazon EC2 with the help of Exhibitor. This was done as a part of my final year project so i thought i should share this because it might be helpful to others. I assume that you know about ZooKeeper otherwise you want be reading this article right. anyway if you want to learn about ZooKeeper you can check out the ZooKeeper home page here.


So i will first introduce you to Exhibitor its actually a supervisory system that is built using java technology to monitor and supervise ZooKeeper. It provides some cool features that will help you manage your ZooKeeper instances. You can download Exhibitor here. And if you want to learn more about Exhibitor take a look at there wiki page here. Exhibitor allows you to configure ZooKeeper instances through a very clean web interface. the config panel will look like this.

As you can see you can define the data dir and the ZooKeeper installation dir. lets talk about the server list after we get the servers set up in Amazon EC2.

Setting up Servers in Amazon EC2

First you will have to create an account at Amazon to get Amazon web services such as EC2. You will need an credit card to create an account but all the work needed to get ZooKeeper running can be done under the free tier so it want cost you anything. So when you got your account set up you can find your way into the EC2 console. In the console you can create new instances, i want go into details on how to set up servers, Amazon has pretty neat set of documentation so you can refer them here. So using the console create 3 Ubuntu servers preferably Ubuntu 12.04 Servers.

I assume that you used the quicklaunch security group or the default security group when creating the servers. Its fine even if you created a custom group. You can change the setting in your security group from the Security Groups option in the navigation panel. So go over there and change the rules to free the ports that you will be using, keep the source as you will need to free the ssh port 22 and other ports that you will be using in Zookeeper and 8080 for Exhibitor. if you are feeling lazy you can just use the All TCP  rule in the drop down list.

You can connect to the server through ssh. how to do this is explained step by step here.

Installing ZooKeeper and Exhibitor

Now that you can access  the servers lets install ZooKeeper and Exhibitor. create a folder in the home dir and download ZooKeeper and Exhibitor and extract them. Create a dir to be used as the data dir for ZooKeeper in my case i used "/home/ubuntu/zookeeper/data/" you have to repeat this for all 3 servers. And since we are using ZooKeeper in the replicated mode you will need to create the myid files and assign 1,2 and 3 for the three servers.

Installing Java and setting classpath variables 

You will have to install Java jre and jdk before you can run anything on the server. it would be better to install sun-java6 take a look at my previous article if you run into trouble installing sun-java6 on the server.

Now you have to add the following lines into the .bashrc file in your home dir.

export JAVA_HOME=/usr/lib/jvm/java-6-sun-
export PATH=$PATH:/usr/lib/jvm/java-6-sun-$JAVA_HOME/bin
export CLASSPATH=/usr/lib/jvm/java-6-sun-

And at last you need to comment the following line that can be found on the top of the .bashrc file or the settings will not be available non-interactive calls.

[ -z "$PS1" ] && return

Lets get things running
Now go into Exhibitor and run the Exhibitor jar file if you want to keep it running even after you close your ssh connection use the command "nohup" like "nohup java -jar ....". Now you should be able to access Exhibitor through your browser using the public DNS of the server it should be somthing like "" . So the URL for Exhibitor will be something like the following. and you do this for all three servers and get the interface for each server.

In the config tab enter the ZooKeeper installation dir, in my case it is "/home/ubuntu/zookeeper/zookeeper-3.4.2/" and you can also set the data dir.  You can change the additional config information if you like i am using the following settings.


Set the client port to the port you want i am using 2185 for this one. you can change them to what you like and they can be different in each 3 Exhibitor instance. The connect port and the election port need to be same in all three config's so i will be using 2900 and 3900 in all 3 instances.

The server list

Now the server list is a comma separated string of the ip of the servers. lets say the following are the public and private ip's of the three servers. these can be found from the Amazon console.

1. public ip -
    private ip - ip-1x-xxx-x-xxx

2. public ip -
    private ip - ip-2x-xxx-x-xxx

3. public ip -
    private ip - ip-3x-xxx-x-xxx

So the server list of the first server will be ( the one with myid set to 1 in the data dir ).

1: ip-1x-xxx-x-xxx,,

second server,2:ip-2x-xxx-x-xxx,

third server,,3:ip-3x-xxx-x-xxx

After you get the config's set properly click commit on each exhibitor interface. after a few minutes  you should be able to see the three servers in the control panel tab. So now you should have your ZooKeeper Quorum up and running under Exhibitor.

 If you find this post interesting or run into and problems when following the post please leave a comment. I may be able to help you because i ran into a ton of errors while i was setting this up for the first time.


  1. You don't actually tell the secret location where to get the binaries from now that Netflix has decided to delete them from Maven Central. Did Netflix contact you also and demand that you delete that information? I guess they're having second thoughts about their half-ass open source attempt.

    1. Hi

      Actually we built it from the source code. we also couldn't locate the binaries. you can build it using gradle :).

  2. did you set this up as a standalone server too ? if yes, besides -c file what other configuration parameters did you have to set for it to work correctly ?

  3. Hi

    by Standalone server do you mean a single server with Exhibitor or just a Zookeeper server in Amazon EC2?. both are pretty straight forward if you want just a Zookeeper Server follow the steps given in For exhibitor it should also easy u don't even need all those configurations with IP's.


Post a Comment

Popular posts from this blog

Writing Unit Tests to test JMS Queue listener code with ActiveMQ

Reading and Writing Binary files in java - Converting Endianness ( between Big-endian byte order and Little-endian byte order)

How to set up a Apache Spark cluster in your local machine