ZooKeeper Installation

  1. Install ZooKeeper packages

    # apt-get install openjdk-8-jre-headless
    # apt-get install zookeeper zookeeperd zkdump
  2. Configure ZooKeeper

    1. Common Configuration

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

      server.1=nsdb1:2888:3888
      server.2=nsdb2:2888:3888
      server.3=nsdb3:2888:3888
      autopurge.snapRetainCount=10
      autopurge.purgeInterval =12
      [Important]Important

      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

      1. NSDB Node 1

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

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

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

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

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

        # echo 3 > /var/lib/zookeeper/myid
  3. Restart ZooKeeper

    # service zookeeper restart
  4. 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 127.0.0.1 2181
    imok

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

    $ echo stat | nc 127.0.0.1 2181
    Zookeeper version: 3.4.5--1, built on 06/10/2013 17:26 GMT
    Clients:
     /127.0.0.1:34768[0](queued=0,recved=1,sent=0)
     /192.0.2.1:49703[1](queued=0,recved=1053,sent=1053)
    
    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.