Starting the Membership Servers
zkServer.sh shell script, you need to set the maximum Java heap
size, which determines if ZooKeeper swaps to the file system. The Java maximum heap size
should not be larger than the amount of available real memory. Edit the
zkEnv.sh shell script to add a new line with the
JVMFLAGS environment variable setting the maximum Java heap size to 4
GB. Upon startup, the zkServer.sh shell script sources the
zkEnv.sh shell script to include this new environment variable.
The ZooKeeper shell scripts are located in the ZooKeeper server /bin directory. For example, if you unpacked the apache-zookeeper-3.8.4-bin.tar.gz file into the /grid/membership directory on each membership server, then the zkEnv.sh and zkServer.sh shell scripts are located in the /grid/membership/apache-zookeeper-3.8.4-bin/bin directory.
The following example edits the zkEnv.sh shell script and adds the JVMFLAGS=Xmx4g configuration within the zkEnv.sh script after the line for ZOOKEEPER_PREFIX.
ZOOBINDIR="${ZOOBINDIR:-/usr/bin}"
ZOOKEEPER_PREFIX="${ZOOBINDIR}/.."
JVMFLAGS=-Xmx4gStart each membership server by running the zkServer.sh start shell script on each server.
% setenv ZOOCFGDIR /grid/membership/apache-zookeeper-3.8.4-bin/conf
% /grid/membership/apache-zookeeper-3.8.4-bin/bin/zkServer.sh startYou can verify the status for each membership server by executing the zkServer.sh status command on each membership server:
% /grid/membership/apache-zookeeper-3.8.4-bin/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /grid/membership/apache-zookeeper-3.8.4-bin/conf/zoo.cfg
Mode: { leader | follower }If the membership server is not running, is not in replicated mode, or there is not a majority executing, these errors are displayed:
ZooKeeper JMX enabled by default
Using config: /grid/membership/apache-zookeeper-3.8.4-bin/conf/zoo.cfg
Error contacting service. It is probably not running.Additionally, you can verify if a membership sever is running in a non-error state with the ruok ZooKeeper command. The command returns imok if the server is running. There is no response otherwise. From a machine within the network, run:
% echo ruok | nc ms_host1 2181
imokFor statistics about performance and connected clients, use the stat ZooKeeper command. From a machine within the network, run:
% echo stat | nc ms_host1 2181Once the membership servers are started, you can create your grid. See Configure a Grid as a Membership Service Client.