XAP uses ZooKeeper for storing the id of the primary Space for each partition, this is used for MemoryXtend grid only.When a partition is started, the primary election mechanism will elect a primary Space randomly (or on basis of first-ready) but will wait for the last primary to take the role of primary the Space.
To start a ZooKeeper instance on a machine, launch the
gs-agent script located in the
<XAPHOME>/bin folder. This will start the Grid Service Agent, which is responsible for starting and managing the other Service Grid components (GSC, GSM, etc.). For example, to start two GSCs, two global GSMs and two global LUSs and a ZooKeeper, use the following command:
gs-agent gsa.gsc 2 gsa.global.gsm 2 gsa.global.lus 2 gsa.zk 1
For reliable ZooKeeper services, you should deploy ZooKeeper in a cluster known as an Ensemble . As long as a majority of the Ensembles are up, the service will be available. ZooKeeper requires a majority, it is best to use an odd number of machines.
Since every machine that is part of the ZooKeeper ensemble should know about every other machine in the ensemble, ZooKeeper instances are using the
XAP_ZOOKEEPER_SERVERS environment variable or the
-Dorg.openspaces.grid.zookeeper.servers system property. It accepts a comma separated list of
host:port:port, the first port is used by followers to connect to the leader, and the second is for the leader election. By default it is configured with
The ip/hostname above should be the same as it configured in
XAP_NIC_ADDR as it explained here.
Then start a ZooKeeper instances on an odd number of machines like the example below:
Machine A: gs-agent gsa.gsc 0 gsa.global.gsm 2 gsa.global.lus 2 gsa.zk 1 Machine B: gs-agent gsa.gsc 0 gsa.global.gsm 2 gsa.global.lus 2 gsa.zk 1 Machine C: gs-agent gsa.gsc 2 gsa.global.gsm 0 gsa.global.lus 0 gsa.zk 1
Like other Grid Service Components you can use the component-specific configuration for specifying ZooKeeper settings. This is set using the environment variable:
export XAP_ZOOKEEPER_JAVA_OPTIONS=-Xmx256m ./gs-agent.sh
set XAP_ZOOKEEPER_JAVA_OPTIONS=-Xmx256m call gs-agent.bat
The ZooKeeper configuration is provided by configuration file which is located by default at
<XAP Root>\config\zookeeper\zoo.cfg, you can change it location using
XAP_ZOOKEEPER_SERVER_CONFIG_FILE environment variable or the
-Dorg.openspaces.grid.zookeeper.config-file system property.
More information on how to configure ZooKeeper can be found here.