How to Install ZooKeeper

Learn how to download and install ZooKeeper.

Installing ZooKeeper

Download ZooKeeper from the site below and extract it to an appropriate location.

% mkdir zookeeper
% mv apache-zookeeper-3.8.1-bin.tar.gz zookeeper
% cd zookeeper
% tar -zxvf apache-zookeeper-3.8.1-bin.tar.gz

After extraction, the apache-zookeeper-3.8.1-bin directory is created.

ZooKeeper Configuration File

To start ZooKeeper, a configuration file is required, so create the conf/zoo.cfg file.

First, check the files in conf.

% cd apache-zookeeper-3.8.1-bin/conf
% ls
configuration.xsl logback.xml       zoo_sample.cfg

Create conf/zoo.cfg with the following content.

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper
clientPort=2181
  • tickTime: heartbeat time in milliseconds.
  • dataDir: path for storing in-memory database snapshots and logs written when the database is updated.
  • clientPort: port that listens for client connections.

Running ZooKeeper

You can now run ZooKeeper.

% bin/zkServer.sh start

ZooKeeper Replication

If you install and run it this way, ZooKeeper runs in standalone mode and has no replication. Therefore, if the ZooKeeper process dies, the service will stop.
To apply replication, see Running Replicated ZooKeeper.