Skip to content

Cluster Configuration Guide


AS400Gateway for AWS product is a self-sufficient AMI that can be used in stand-alone single-node configuration to quickly surface IBM i (AS400) programs, commands and messages via standards based REST API. To ensure the resulting solution can scale to support high transaction volumes and improve the resiliency, it is possible to run multiple "workers" in a shared cluster mode. Each node in the cluster can process the admin or functional request, and the configuration data is propagated across all nodes in near real time.

The cluster configuration generally consists of two steps:

  1. H2 Cluster Configuration
  2. Load Balancer configuration

H2 Cluster Configuration

H2 Cluster Configuration includes following steps

Step 1 - Transfer H2 jar file (in example used 1.4.199 version - h2-1.4.199.jar) to instance

scp [...]/h2- 1.4.199.jar ec2-user@[Instance-IP]:/[copying folder]/ 

Connect to Instance

ssh ec2-user@[Instance-IP] 

Copy H2 jar to executable-jars folder

sudo cp /[copying folder]/h2-1.4.199.jar [project folder]/executable-jars/ 


Step 2 - Start H2 Server in Background Mode using & operator

sudo java -cp h2-1.4.199.jar -tcp -tcpAllowOthers -tcpPort [H2-port] -ifNotExists & 

[H2-port] - port where H2 server will run in instance

Then type disown to detach it from your shell


P.s. Steps 1-2 should be taken for both instances

Step 3 - Create H2 Cluster

Start this command from any instance

java -cp h2-1.4.199.jar -urlSource jdbc:h2:tcp://[first Instance-IP]:[H2-port]/./src/main/resources/connections -urlTarget jdbc:h2:tcp://[second Instance-IP]:[H2-port]/./src/main/resources/connections -user sa -password password -serverList [first Instance-IP]:[H2-port],[second Instance-IP]:[H2-port] 

After this you should see a new file on src/main/resources folder in both instances with the same creation date and time

image image

Step 4 - Change datasource URL in in [project folder]/config folder


spring.datasource.url=jdbc:h2:tcp://[first Instance-IP]:[H2-port],[second Instance-IP]:[H2-port]/./src/main/resources/connection

Step 5 - Add JVM parameter –Dh2.clustering.enabled=true in as400-common-api-1.0.0.conf file in [project folder]/executable-jars/ folder


P.s. Steps 4-5 should be taken for both instances

Additional information you can find here: H2 Clustering

Load Balancer configuration

** Note - this configuration is provided only as an example. Companies may operate in the AWS environments with different requirements, standards and services

** TODO sample steps to configure LB to direct the Admin and Functional API traffic to one of the available VMs.