ZooKeeper Installation

  1. Install ZooKeeper packages

    # yum install java-1.8.0-openjdk-headless
    # yum install zookeeper zkdump nmap-ncat
  2. Configure ZooKeeper

    1. Common Configuration

      Edit the /etc/zookeeper/zoo.cfg file to contain the following:

      autopurge.purgeInterval =12

      Create data directory:

      # mkdir /var/lib/zookeeper/data
      # chown zookeeper:zookeeper /var/lib/zookeeper/data

      For production deployments it is recommended to configure the storage of snapshots in a different disk than the commit log, this is done by setting the parameters dataDir and dataLogDir in zoo.cfg. In addition we advice to use an SSD drive for the commit log.

    2. Node-specific Configuration


      If using CentOS 7.3 please use /var/lib/zookeeper/myid as the path for the host ID

      1. NSDB Node 1

        Create the /var/lib/zookeeper/data/myid file and edit it to contain the host’s ID:

        # echo 1 > /var/lib/zookeeper/data/myid
      2. NSDB Node 2

        Create the /var/lib/zookeeper/data/myid file and edit it to contain the host’s ID:

        # echo 2 > /var/lib/zookeeper/data/myid
      3. NSDB Node 3

        Create the /var/lib/zookeeper/data/myid file and edit it to contain the host’s ID:

        # echo 3 > /var/lib/zookeeper/data/myid
  3. Create Java Symlink

    # mkdir -p /usr/java/default/bin/
    # ln -s /usr/lib/jvm/jre-1.8.0-openjdk/bin/java /usr/java/default/bin/java
  4. Enable and start ZooKeeper

    # systemctl enable zookeeper.service
    # systemctl start zookeeper.service
  5. Verify ZooKeeper Operation

    After installation of all nodes has been completed, verify that ZooKeeper is operating properly.

    A basic check can be done by executing the ruok (Are you ok?) command on all nodes. This will reply with imok (I am ok.) if the server is running in a non-error state:

    $ echo ruok | nc 2181

    More detailed information can be requested with the stat command, which lists statistics about performance and connected clients:

    $ echo stat | nc 2181
    Zookeeper version: 3.4.5--1, built on 06/10/2013 17:26 GMT
    Latency min/avg/max: 0/4/255
    Received: 1055
    Sent: 1054
    Connections: 2
    Outstanding: 0
    Zxid: 0x260000013d
    Mode: follower
    Node count: 3647
Questions? Discuss on Mailing Lists or Chat.
Found an error? Report a bug.