• Home
  • Docker
  • Kubernetes
  • LLMs
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • Archived
ZooKeeper | Install and configure a ZooKeeper Cluster on different hosts
  1. Download and Install Apache ZooKeeper
  2. Configure a ZooKeeper Cluster on 3 hosts
  3. Start/Stop ZooKeeper

  1. Download and Install Apache ZooKeeper
    Download Apache ZooKeeper "3.9.3": http://zookeeper.apache.org/releases.html

    In the following, we will install ZooKeeper in 3 different hosts: "zkhost1", "zkhost2", and "zkhost3"

    On each host, extract the file "apache-zookeeper-3.9.3-bin.tar.gz" in the folder you want to install ZooKeeper:
    ► /opt/apache-zookeeper-3.9.3-bin


    Optional: Create a symbolic link of the ZooKeeper installation folder:

    Change the folders permissions (if needed):
  2. Configure a ZooKeeper Cluster on 3 different hosts
    On each host ("zkhost1", "zkhost2", and "zkhost3"), do the following:

    Create the data and logs directories:
    • Create the folder "data": "/opt/zookeeper/data"

    • Create the folder "data-log": "/opt/zookeeper/data-log"

    • Create the log folder: "/opt/zookeeper/logs"

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

    Initialize the server id for each ZooKeeper instance:
    • First instance ("zkhost1"):

    • Second instance ("zkhost2"):

    • Third instance ("zkhost3"):

    Adjust the configuration file "conf/zoo.cfg":
    • Define the property "dataDir": dataDir=/opt/zookeeper/data

    • Define the property "dataLogDir": dataLogDir=/opt/zookeeper/data-log

    • Add a static configuration for each ZooKeeper instance on the 3 hosts:

    • 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).

    Example: ZooKeeper configuration file "zoo.cfg" (/opt/zookeeper/conf/zoo.cfg)
  3. Start/Stop ZooKeeper
    To start ZooKeeper instances, run the following command on each host:

    To stop ZooKeeper instances, run the following command on each host:

© 2025  mtitek