To configure a ZooKeeper ensemble, you need to configure the file "
zoo.cfg
" of each instance to contain the list of all instances.
And each instance must have a "
myid
" file (under the data directory) that has its ID number (used in the file "
zoo.cfg
").
To add a ZooKeeper instance to the ZooKeeper ensemble, you need to add the following parameter to the file "
zoo.cfg
":
-
<id>
: the ZooKeeper instance id.
Must be an integer, but it's not required to start with 0 or to be sequential.
Each ZooKeeper instance must have a file in the "dataDir
" directory with the name "myid
" that must contains its id number.
-
<zk_host_address>
: the host name or ip address where the ZooKeeper instance is running
-
<zk_peer_port>
: (peer tcp port) is used by peer ZooKeeper instances to communicate with each other.
-
<zk_leader_port>
: (leader tcp port) is used for the ZooKeeper leader election.
-
<zk_role>
: ZooKeeper instances roles ("participant
", "observer
"). The role is optional, and if not specified it defaults to "participant
".
-
<zk_client_port_address>
: The client port address is optional, and if not specified it defaults to "0.0.0.0
".
-
<zk_client_port>
: A client port of a ZooKeeper instance is the port on which the ZooKeeper instance accepts client connection requests.
The ZooKeeper instances use the peer, leader, and client ports to do different type of communications between each other,
but the ZooKeeper clients use only the client ports to communicate with the ensemble.