• Home
  • Docker
  • Kubernetes
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • CI
  • Install
  • Samples
  • Archived
ZooKeeper | Install and configure a ZooKeeper Cluster on the same host
  1. Download Apache ZooKeeper
  2. Configure a ZooKeeper Cluster on the same host
  3. Start/Stop ZooKeeper

  1. Download Apache ZooKeeper
    Download Apache ZooKeeper "3.9.3": http://zookeeper.apache.org/releases.html
  2. Configure a ZooKeeper Cluster on the same host
    Extract the content of "apache-zookeeper-3.9.3-bin.tar.gz" file to three locations of your choice:
    ► /opt/zookeeper-i1
    ► /opt/zookeeper-i2
    ► /opt/zookeeper-i3



    Change the folders permissions (if needed):


    First, for each ZooKeeper binary distribution ("zookeeper-i1", "zookeeper-i2", "zookeeper-i3"), you need to do the following instructions:
    • Create the folder "data":

    • Create the folder "data-log":

    • Create the log folder "logs":

    • Copy the file "conf/zoo_sample.cfg" to "conf/zoo.cfg":

    • Initialize the server id for each ZooKeeper instance:

    For each ZooKeeper binary distribution you will need to modify the "conf/zoo.cfg" file:
    • Modify the properties "dataDir" and "dataLogDir":

      • First instance ("/opt/zookeeper-i1/conf/zoo.cfg"):

      • Second instance ("/opt/zookeeper-i1/conf/zoo.cfg"):

      • Third instance ("/opt/zookeeper-i1/conf/zoo.cfg"):

    • Add a static configuration for each ZooKeeper instance:

    • Remove the properties "clientPort" and "clientPortAddress".
      You should not include these parameters in the ZooKeeper configuration "conf/zoo.cfg" file. They should be part of the ZooKeeper instances configuration (see above).

    • Because the default port is 8080 for the Jetty embedded server, You need to add the property "admin.serverPort" to override the default value. This allow each instance to have its unique port for AdminServer http interface.
      Reminder: this step is needed because we are configuring multiple ZooKeeper instances on the same host.

      • First instance ("/opt/zookeeper-i1/conf/zoo.cfg"):

      • Second instance ("/opt/zookeeper-i2/conf/zoo.cfg"):

      • Third instance ("/opt/zookeeper-i3/conf/zoo.cfg"):

    Example: ZooKeeper configuration file "zoo.cfg"

    /opt/zookeeper-i1/conf/zoo.cfg
    :
    /opt/zookeeper-i2/conf/zoo.cfg:
    /opt/zookeeper-i3/conf/zoo.cfg:
  3. Start/Stop ZooKeeper
    To start ZooKeeper instances:

    To stop ZooKeeper instances:
© 2025  mtitek