Database Reference
In-Depth Information
its own dedicated device (not just a partition), a ZooKeeper server can maximize the rate
at which it writes log entries to disk, which it does sequentially without seeking. Because
all writes go through the leader, write throughput does not scale by adding servers, so it is
crucial that writes are as fast as possible.
If the process swaps to disk, performance will be adversely affected. This can be avoided
by setting the Java heap size to less than the amount of unused physical memory on the
machine. From its configuration directory, the ZooKeeper scripts will source a file called
java.env , which can be used to set the JVMFLAGS environment variable to specify the
heap size (and any other desired JVM arguments).
Configuration
Each server in the ensemble of ZooKeeper servers has a numeric identifier that is unique
within the ensemble and must fall between 1 and 255. The server number is specified in
plain text in a file named myid in the directory specified by the dataDir property.
Setting each server number is only half of the job. We also need to give every server all
the identities and network locations of the others in the ensemble. The ZooKeeper config-
uration file must include a line for each server, of the form:
server. n = hostname : port : port
The value of n is replaced by the server number. There are two port settings: the first is
the port that followers use to connect to the leader, and the second is used for leader elec-
tion. Here is a sample configuration for a three-machine replicated ZooKeeper ensemble:
tickTime = 2000
dataDir = /disk1/zookeeper
dataLogDir = /disk2/zookeeper
clientPort = 2181
initLimit = 5
syncLimit = 2
server.1 = zookeeper1:2888:3888
server.2 = zookeeper2:2888:3888
server.3 = zookeeper3:2888:3888
Servers listen on three ports: 2181 for client connections; 2888 for follower connections,
if they are the leader; and 3888 for other server connections during the leader election
phase. When a ZooKeeper server starts up, it reads the myid file to determine which server
it is, and then reads the configuration file to determine the ports it should listen on and to
discover the network addresses of the other servers in the ensemble.
Search WWH ::




Custom Search