Configure a server cluster with keepalived

This section describes how to configure a two-server cluster using the Keepalived page in the WAI. This example assumes that the server IP addresses are as follows:

Server IP Address
Server1 eth0 IP Address 192.168.0.10
Server2 eth0 IP Address 192.168.0.20
Cluster Virtual IP Address 192.168.0.100

For example, to connect directly to the API Gateway running on Server1,you can access a URL such as http://192.168.0.10:8080/healthcheck. Similarly, for Server2, you can access a URL such as http://192.168.0.20:8080/healthcheck. When the keepalived service is active, you can access a URL such as http://192.168.0.100:8080/healthcheck which is served by Server1 or Server2.

Configure the master system

The following steps describe how to configure the master server in the cluster:

  1. Log in to the WAI on Server1. This system is configured as the master or highest priority system in the cluster.
  2. Click the Keepalived link on the left of the WAI. This displays the status of the cluster, and includes details such as the Virtual IP, the Healthcheck Status, and whether this server is currently serving on the Virtual IP.
  3. To set this system as the master, click the Set Default Master button. This sets some useful defaults in the configuration such as the priority of this server. After confirmation that the configuration has changed, click the Return to Keepalived link.
  4. Some of the defaults in the configuration file must be changed, so click the Edit Config Files button at the bottom of the page.
  5. On the Edit Config Files page, change the virtual_ipaddress section to 192.168.0.100/24 (or whatever IP address you have chosen). The address is specified in CIDR format, with a subnet mask of /24 . Click the Save button to apply the configuration.
  6. Edit keepalived configuration file
  7. When the configuration is applied, you can see the new IP address in the Virtual IP row in the keepalived Status table. If the API Gateway is currently running, you should also see that the Healthcheck Status is Connection OK.
  8. Click the Start keepalived button.
  9. When keepalived is started, you can see that the Configuration State is MASTER, and the Current State is Active in the keepalived Status table.

Configure the backup system

 The following steps describe how to configure the backup system in the cluster:

  1. Log in to the WAI on Server2. This system is configured as the backup system. If there is an issue on Server1, this system is promoted to master state and serves requests on the Virtual IP address.
  2. Click the Keepalived link on the left of the WAI.
  3. To set this system as the backup, click the Set Default Backup button. After confirmation that the configuration has changed, click the Return to Keepalived link.
  4. Some of the defaults in the configuration file must be changed, so click the Edit Config Files button at the bottom of the page.
  5. On the Edit Config File page, change the virtual_ipaddress section to 192.168.0.100/24 (or whatever IP address you have chosen). The address is specified in CIDR format, with a subnet mask of /24 . Click the Save button to apply the configuration.
  6. When the configuration is applied, you can see the new IP address in the Virtual IP row in the keepalived Status table. If the API Gateway is currently running, you should also see that the Healthcheck Status is Connection OK.
  7. Click the Start keepalived button.
  8. When keepalived is started, you can see that the Configuration State is Backup, and the Current State is Standby in the keepalived Status table.
  9. Try to connect to a URL using the Virtual IP address, and it should work as expected.

Configure multiple clusters on the same network

To have more than one discrete cluster running on the same network, you must modify the default configuration. The settings that you need to change in the keepalived configuration file are as follows:

  • virtual_router_id
  • auth_pass

For each cluster, you must specify a unique value for these settings. Each system in that cluster must use the same value in its configuration file.

Related Links