Skip to content

Cluster Configuration Guide

Overview

InfoConnect 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 - Start H2 Server in Background Mode using & operator

Connect to Instance and open [project-folder]/executable-jars directory

ssh ec2-user@[Instance-IP] 

image

Run the following command to start H2 server

sudo java -cp h2-1.4.199.jar org.h2.tools.Server -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

disown

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

Step 2 - Create H2 Cluster

Start this command from any instance

java -cp h2-1.4.199.jar org.h2.tools.CreateCluster -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 h2db -password password -serverList [first Instance-IP]:[H2-port],[second Instance-IP]:[H2-port] 

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

image image

Step 3 - Change datasource URL in application.properties in [project folder]/config folder

image

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

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

image

P.s. Steps 3-4 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

To create a Load Balancer using the AWS Management Console, complete the following tasks: 1. Configure target group 2. Configure Load Balancer and Listener

Step 1: Configure target group

Configuring a target group allows you to register EC2 instances through which Load Balancer will distribute client requests

To configure your target group 1. In the navigation pane open Target Groups and choose Create target group 2. In Basic configuration do the following: - For Choose target type select Instances to register targets by instance ID - Enter target group name in Target group name - For Protocol choose TCP and enter 8080 as Port (default port for connector) - Choose Next 3. In Register targets select one or more instances and then choose Include as pending below 4. Choose Create target group

Step 3: Configure Load Balancer and Listener

To configure Load Balancer and Listener 1. In the navigation pane open Load Balancers, choose Create Load Balancer, then under Network Load Balancer choose Create 2. In Basic configuration do the following: - Enter Load Balancer name - For Scheme choose Internet-facing to route requests from clients to targets over the internet - For IP address type use IPv4 if your clients use IPv4 addresses to communicate with the load balancer. Use Dualstack if your clients use both IPv4 and IPv6 addresses 3. In Network mapping do the following: - For VPC, select the VPC that you used for instances - For Mappings, select one or more zones where instances are running 4. In Listeners and Routing do the following: - For Listeners, the default is a listener that accepts TCP traffic on port 80. Change the port on 8080 - For Default action, choose target group that was created before 5. Choose Create load balancer

Step 4: Test Load Balancer

  1. Select newly created Load Balancer in Load Balancers pane
  2. Copy the DNS name of the Load Balancer (for example, my-load-balancer-1234567890abcdef.elb.us-east-2.amazonaws.com). Paste the DNS name into the address field of an internet-connected web browser and add listener port and /admin/connections.

Address field should look like this:

my-load-balancer-1234567890abcdef.elb.us-east-2.amazonaws.com:8080/admin/connections

If everything is working, the browser displays authorization window to paste username and password. If we authorize we should see array of available connections.

Additional information about configuring Load Balancer you can find here: Creating Network Load Balancer