Skip to content

Cluster Configuration Guide

Overview

The InfoConnect Hub for AWS is a self-contained Amazon Machine Image (AMI) that runs on a single node and surfaces IBM i programs, commands and messages as REST APIs. To handle higher transaction volumes and improve resilience, you can run several nodes ("workers") as a cluster. Each node processes Admin API and Functional API requests, and configuration changes are propagated to all nodes in near real time.

This guide describes an example cluster of two AWS instances. Configure the cluster in two parts:

  1. Create an H2 database cluster.
  2. Configure a load balancer in front of the nodes.

Note

A newer alternative is available. The Hub can synchronize several instances through a shared external metadata database (MySQL or IBM i) by setting db.sync.enabled=true. See Distribution archive and Multiple Hub replicas.

H2 cluster configuration

Note

The steps below show the layout of the AWS Marketplace instance. In the distribution archive, the H2 JAR is info-connect-hub/executable-jars/h2-2.2.220.jar, the database is ./info-connect-hub/config-db, the database credentials are spring.datasource.username and spring.datasource.password in info-connect-hub/config/application.properties, and JVM options go to extraOpts in the [jvm.hub] section of start-scripts/config/modules.manifest.ini.

H2 is the embedded database in which the Hub stores its metadata. Perform steps 1, 2, 4 and 5 on both instances. Run step 3 on one instance only.

  1. Connect to the instance and open the <project-folder>/executable-jars directory. <project-folder> is /opt/info-connect-hub on an AWS Marketplace instance.

    ssh ec2-user@<instance-ip>
    

    Terminal listing of the executable-jars folder with the h2-1.4.199.jar file highlighted

  2. Start the H2 server in the background. <h2-port> is the port on which the H2 server runs on the instance.

    sudo java -cp h2-1.4.199.jar org.h2.tools.Server -tcp -tcpAllowOthers -tcpPort <h2-port> -ifNotExists &
    

    Then detach the server from your shell:

    disown
    
  3. Create the H2 cluster. Run the following command on any one 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>
    

    On both instances, the src/main/resources folder now contains a new connections.mv.db file with the same creation date and time.

    Terminal listing of the src/main/resources folder on the first instance with the connections.mv.db file highlighted

    Terminal listing of the src/main/resources folder on the second instance with the connections.mv.db file highlighted

  4. Change the datasource URL in application.properties in the <project-folder>/config folder:

    Terminal listing of the config folder with the application-dev.properties file highlighted

    spring.datasource.url=jdbc:h2:tcp://<first-instance-ip>:<h2-port>,<second-instance-ip>:<h2-port>/./src/main/resources/connections
    
  5. Add the JVM parameter -Dh2.clustering.enabled=true to the as400-common-api-1.0.0.conf file in the <project-folder>/executable-jars/ folder:

    Content of the as400-common-api-1.0.0.conf file with the -Dh2.clustering.enabled=true parameter highlighted

For more information, see H2 clustering.

Load balancer configuration

This configuration is an example only. Your AWS environment can have different requirements, standards and services.

To create a load balancer in the AWS Management Console, configure a target group first, then the load balancer and its listener.

Configuring the target group

A target group registers the EC2 instances to which the load balancer distributes client requests.

  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 a name in Target group name.
    • For Protocol, choose TCP, and enter 8080 as Port (the default port of the Hub).
    • Choose Next.
  3. In Register targets, select one or more instances and choose Include as pending below.
  4. Choose Create target group.

Configuring the load balancer and listener

  1. In the navigation pane, open Load Balancers, choose Create Load Balancer, and under Network Load Balancer choose Create.
  2. In Basic configuration, do the following:
    • Enter a name for the load balancer.
    • For Scheme, choose Internet-facing to route client requests to the targets over the internet.
    • For IP address type, choose IPv4 if your clients use IPv4 addresses. Choose Dualstack if your clients use both IPv4 and IPv6 addresses.
  3. In Network mapping, do the following:
    • For VPC, select the VPC that your instances use.
    • For Mappings, select one or more zones where the instances run.
  4. In Listeners and routing, do the following:
    • For Listeners, change the port of the default listener (TCP, port 80) to 8080.
    • For Default action, choose the target group that you created.
  5. Choose Create load balancer.

Testing the load balancer

  1. In the Load Balancers pane, select the new load balancer.
  2. Copy its DNS name, for example my-load-balancer-1234567890abcdef.elb.us-east-2.amazonaws.com.
  3. Paste the DNS name into the address field of a browser, and add the listener port and /admin/connections:

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

The browser shows an authorization dialog. Enter the Admin API user name and password. The browser then shows the list of available connections.

For more information, see Creating a Network Load Balancer.