Wednesday, March 30, 2016

Setup ZooKeeper cluster in CentOS VMs.

This post summarizes my experience on setting up a zookeeper cluster in CentOS VMs.

Before start, setup three VMs with the following hostname/ipaddress (Refer to this on how to set up and configure CentOS VMs using VirtualBox


1. Edit /etc/hosts

On each VM, edit /etc/hosts to add the following lines: zoo01 zoo02 zoo03

2. Download and configure zookeeper

2.1 Download zookeeper

On each VM, download and unzip the zookeeper to the folder "/root/zookeeper".

2.2. Configure zookeeper

On each VM, run the following command to edit the /root/zookeeper/conf/zoo.cfg:

`cp zookeeper/conf/zoo_sample.cfg zookeeper/conf/zoo.cfg
`vi zookeeper/conf/zoo.cfg

In the zookeeper/conf/zoo.cfg, add the following configuration:



Run the following comand to create the directory for holding the data storage for zookeeper in each VM (the /root/zookeeper_data/myid must have an unique id on each VM):

`ssh root@zoo01
`mkdir /root/zookeeper_data
`touch /root/zookeeper_data/myid
`echo 1 >> /root/zookeeper_data/myid
`ssh root@zoo02
`mkdir /root/zookeeper_data
`touch /root/zookeeper_data/myid
`echo 2 >> /root/zookeeper_data/myid
`ssh root@zoo03
`mkdir /root/zookeeper_data
`touch /root/zookeeper_data/myid
`echo 3 >> /root/zookeeper_data/myid

3. Start zookeeper cluster

To start the zookeeper cluster, on each VM zoo01/2/3, run the following command:

`zookeeper/bin/ start zookeeper/conf/zoo.cfg

(Note that for testing, you may want to use the command "start-foreground" instead of "start")

4. Test zookeeper running

To check whether the zookeeper cluster is running, run the following command:

`zookeeper/bin/ status

To testing the zookeeper cluster, run the following command:

`zookeeper/bin/ -server,,

No comments:

Post a Comment