Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Apache ZooKeeper quorum configuration generator
Branch: master


Generate configuration for ZooKeeper ensemble

Author: Patrick Hunt (follow me on twitter)


This project will generate all of the configuration needed to run a ZooKeeper ensemble. I mainly use this tool for localhost based testing, but it can generate configurations for any list of servers (see the —server option).

What’s Apache ZooKeeper?

From the official site: “ZooKeeper is a high-performance coordination service for distributed applications.”

It exposes common services – such as naming, configuration management, synchronization, and group services – in a simple interface so you don’t have to write them from scratch. You can use it off-the-shelf to implement consensus, group management, leader election, and presence protocols. And you can build on it for your own, specific needs.


This project is licensed under the Apache License Version 2.0


  • Python
  • Cheetah templating package are necessary to run this
    • On ubuntu “sudo apt-get install python-cheetah”
  • Bash

before using the first time (or on update) run the following command

cheetah compile *.tmpl


Usage: [options] zookeeper_dir output_dir

  -h, --help            show this help message and exit
  -c COUNT, --count=COUNT
                        ensemble size (default 3)
  --servers=SERVERS     explicit list of comma separated server names
                        (alternative to --count)
                        first client port (default 2181)
                        first quorum port (default 3181)
                        first election port (default 4181)
  --weights=WEIGHTS     comma separated list of weights for each server (flex
                        quorum only, default off)
  --groups=GROUPS       comma separated list of groups (flex quorum only,
                        default off)
                        maxClientCnxns of server config (default unspecified,
                        ZK default)
                        electionAlg of server config (default unspecified, ZK
                        default - FLE)

Where zookeeper_dir is the location of your ZooKeeper trunk (zkconf copies the jars/confs from this directory into the output_dir to make your life easier). And output_dir is the directory to which we will output the generated files (assumption is that this is a non-existent directory – ie zkconf will create it)

example of typical use; 9 server quorum: —count 9 ~/zookeeper_trunk test9servers —servers “,,” ~/zookeeper_trunk test3servers

example of using weights/groups (only for flex quorum, not typical); 9 servers with 3 groups -c 9 —weights=“1,1,1,1,1,0,0,0,0” —groups=“1:2:3:4:5,6:7,8:9” ~/dev/workspace/gitzk testflexquroum

Running localhost (default) starts client:quorum:election ports as 2181:3181:4181 respectively. Running non-localhost (—servers) starts client:quorum:elections ports for all hosts as 2181:3181:4181.

  • “server:port,server:port,…” – open a client to the server list
  • – status of each of the servers (prints leader | follower if active)
  • – start the ensemble (logs are output to the respective server subdir, localhost only)
  • – stop the ensemble (localhost only)
Something went wrong with that request. Please try again.