ThingWorx High Availability > Installing and Configuring ZooKeeper for ThingWorx HA
Installing and Configuring ZooKeeper for ThingWorx HA
Apache ZooKeeper is an open source solution for managing synchronization of distributed applications. It provides monitoring and leader election services for ThingWorx nodes. At least three ZooKeeper nodes are recommended in a HA configuration. The number of ZooKeeper instances needs to be an odd number to maintain a quorum.
How ThingWorx uses ZooKeeper
Once a ThingWorx node gains leadership, it maintains a session with ZooKeeper and maintains the leadership position. If the session expires because the ThingWorx node fails to respond, the ZooKeeper service selects a ThingWorx standby node to be the next leader. The ThingWorx node is notified that it is now the leader and it takes the leadership position, fully connects to the database, and starts handling traffic.
ZooKeeper nodes also monitor each other’s status. If the active node fails, then a new ZooKeeper leader is elected. This provides high availability for the ZooKeeper service through an internal mechanism for these nodes. The ThingWorx servers are configured with the addresses of all ZooKeeper nodes, which enables them to find the current ZooKeeper leader.
Deploy ZooKeeper
Prior to installing Zookeeper, read and understand all installation documents including documentation for any necessary prerequisite software such as Java. It is important to understand and apply proper settings, including security recommendations. When installing Java for Zookeeper, PTC recommends disabling client-initiated renegotiation (i.e. jdk.tls.rejectClientIntiatedRenegotiation=true).
Download
ZooKeeper can be downloaded from: http://zookeeper.apache.org/releases.html.
Supported Platforms and Software Requirements
Guidelines for deploying ZooKeeper are provided here, including supported platforms and required software: http://zookeeper.apache.org/doc/r3.4.5/zookeeperAdmin.html#ch_deployment
ZooKeeper Clustered Setup
For ThingWorx HA, a clustered (multi-server) setup of ZooKeeper should be deployed. Apache refers a ZooKeeper cluster as an ensemble. Guidance for establishing a ZooKeeper ensemble is provided here: http://zookeeper.apache.org/doc/r3.4.5/zookeeperAdmin.html#sc_zkMulitServerSetup
Configure ThingWorx to use ZooKeeper
With ZooKeeper up and running, ThingWorx HA can be activated. The following process configures ThingWorx to recognize and work with the ZooKeeper servers. One of the steps in this process is only necessary when one ZooKeeper ensemble is supporting multiple ThingWorx HA configurations.
1. Stop all ThingWorx services.
2. Edit platform-settings.json to contain the following:
a. Under BasicSettings, EnableHA should be true. For example
“EnableHA”: false,
b. Under HASettings, CoordinatorHosts should have a comma-delimited list of all ZooKeeper nodes and their ports. For example
“CoordinatorHosts”:
“127.0.0.1:2181,127.0.0.2:2182,127.0.0.3:2181”,
c. (Optional step) Under HASettings, CoordinatorZNode can be used to distinguish this ThingWorx HA configuration when the ZooKeeper ensemble is shared by multiple ThingWorx HA configurations.
"CoordinatorZNode": "MyThingWorxHA",
3. If necessary, propagate the modified platform-settings.json to all ThingWorx servers.
4. Start all ThingWorx servers, one at a time for controlled results.
At this point, all ThingWorx servers should be operating and can accessed. However, only one ThingWorx server should have access to the database and its content.
Was this helpful?