Configuring a Multi-ZooKeeper Cluster

1 minute readScalability

If you plan to use a multi-ZooKeeper cluster, you must configure each ZooKeeper with a unique number from the range 1, 2, 3 for a 3-ZooKeeper cluster or 1, 2, 3, 4, 5 for a 5-ZooKeeper cluster. You must include this number in the following file:

/myid

where < dataDir > is the path you set in your zoo.cfg file.

For example, you can run these commands:

sudo touch /var/lib/zookeeper/myid
sudo -- sh -c 'echo  > /var/lib/zookeeper/myid'

where < number > is the appropriate number between 1 and 3, or 1 and 5.

ZooKeeper Requires a Majority of Nodes to Be Up

ZooKeeper requires a majority of its nodes to be up in order for it to be functional. A majority is:

  • 1 of 1

  • 2 of 3

  • 3 of 5

If a majority of nodes is not up, the expected behavior is a "not currently serving requests" error from ZooKeeper.