Skip to content

Zookeeper

Installing ZooKeeper in Distributed Mode

Follow the steps below to install ZooKeeper in distributed mode:

Step 1: Download and Extract ZooKeeper

Download the latest version of ZooKeeper from the official website and extract it to a directory on each server.

Step 2: Configure ZooKeeper

Create a configuration file named zoo.cfg in the conf directory of each server. The zoo.cfg file should contain the following configuration settings:

tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=ip_address1:2888:3888
server.2=ip_address2:2888:3888
server.3=ip_address3:2888:3888

In the above configuration, replace ip_address1, ip_address2, and ip_address3 with the IP addresses of the three ZooKeeper servers. The tickTime configuration sets the length of a single tick in milliseconds. The dataDir configuration sets the directory where ZooKeeper will store its data. The clientPort configuration sets the port on which ZooKeeper will listen for client connections. The initLimit and syncLimit configurations set the number of ticks that ZooKeeper will wait before timing out. The server configuration sets the ID, IP address, and port number for each server.

Step 3: Start ZooKeeper

Start ZooKeeper on each server by running the following command:

bin/zkServer.sh start

Verify that ZooKeeper is running by running the following command:

bin/zkCli.sh -server ip_address1:2181

Replace ip_address1 with the IP address of one of the ZooKeeper servers. You should see the ZooKeeper command prompt if ZooKeeper is running correctly.

References

  • https://zookeeper.apache.org
  • https://yuzhouwan.com/posts/31915
  • https://static.googleusercontent.com/media/research.google.com/zh-CN//archive/chubby-osdi06.pdf
Feedback