What are floatings IPs?
Floating IPs allow you to have IP redundancy in case of a system fault. This is achieved by monitoring your servers and automatically routing IP addresses to another server if an issue is detected.
You will be provided with a pack of scripts and configuration options that allow utilizing Heficed Terminal API as a way to achieve IP redundancy.
Floating IP solution uses Corosync / Pacemaker as a monitoring system and our API as an IP migration tool. The system can migrate subnets of any size with the help of dynamic routing. Automatic IP migration between different locations is also achievable for subnets that are greater than or equal to /24.
The instructions provided below will get you started with the configuration and use of Floating IP solution:
STEP 1. PREREQUISITES
To start, you need at least two active machines in our infrastructure with CentOS installed. It could be Cloud or Bare Metal servers.
You will need to have IP addresses as well.
Once you have all the necessary servers ready, you need to get more information about them from your Terminal:
Subnet address - subnet you want to be floating;
Subnet CIDR - floating subnet mask in CIDR;
Hostnames - this is displayed in the Terminal of each machine you will use in the High Availability (HA) cluster.
Product type - each machine type that you will use in the HA cluster.
Lastly, since you will be using Heficed API, you need to acquire these specific variables:
To obtain this information, you might want to read through our API documentation.
STEP 2. INSTALLATION
First, download our scripts that are required for this Floating IP solution:
Now, proceed to set up the subnet reassignment script and its configuration.
*The following steps are done with our chosen file paths. Feel free to adjust Python script and its configuration paths as you need. Just make sure to change it in all the scripts where necessary.
**Python Requests Library must be installed on your servers.
Make a new directory for the scripts on both machines:
Place assign-ip.py and api.conf in the following location on both machines:
Proceed to edit and fill the api.conf with the required values. All values should be the same on both servers except the hostname and product type.
Install Corosync, Pacemaker, and PCS
The next step is to get Corosync, Pacemaker and PCS installed on your machines.
Install the software packages on both machines:
yum install pacemaker pcs
The PCS utility creates a new system user during installation named hacluster, with a disabled password. We need to define a password for this user on both servers. This is required for PCS successful synchronization and subnet migration between cluster nodes.
On both machines, run:
Please use the same password on both machines. This password will also be required in further configuration steps.
Set Up the Cluster
Now that we have Corosync, Pacemaker and PCS installed on both servers, we can set up the cluster. To enable and start the PCS daemon, run the following on both machines:
systemctl enable pcsd.service
systemctl start pcsd.service
Authenticate the cluster hosts using the username hacluster and the same password you defined the step before. You will need to enter the primary IP address for each node. From the primary machine, run:
pcs host auth first_machine_primary_IP_address second_machine_primary_IP_address
The output should look like this:
Following this run this command on the primary machine:
pcs cluster setup hacluster first_machine_primary_IP_address second_machine_primary_IP_address
Next, you'll need to start your cluster. Run the following command from the primary machine:
pcs cluster start --all
first_machine_primary_IP_address: Starting Cluster...
second_machine_primary_IP_address: Starting Cluster...
You can check if both nodes have connected to the cluster by running this command on any of the cluster servers:
pcs status corosync
Nodeid Votes Name
2 1 secondary_private_IP_address
1 1 primary_private_IP_address (local)
To get more information about the current status of the cluster, run:
pcs cluster status
The output should be similar to this:
* Stack: corosync
* Current DC: secondary_private_IP_address9 (version 2.0.4-6.el8_3.1-2deceaa3ae) - partition with quorum
* Last updated: Thu Apr 1 10:18:07 2021
* Last change: Tue Mar 30 12:44:39 2021 by root via cibadmin on 184.108.40.206
* 2 nodes configured
* 1 resource instance configured
* Online: [ secondary_private_IP_address primary_private_IP_address ]
Now you should enable the corosync and pacemaker services so they would start on system boot. Run the following on both machines:
systemctl enable corosync.service
systemctl enable pacemaker.service
In our configuration, we recommend disabling STONITH (Shoot The Other Node In The Head). Run the following command on one of the machines:
pcs property set stonith-enabled=false
Create a Floating IP Reassignment Resource Agent
The last thing you need to configure is the resource agent that will execute the IP reassignment script when a failure is detected in the primary cluster node. The resource agent is responsible for creating an interface between the cluster and the resource itself. In this case, the resource is the assign-ip.py script. The cluster requires the resource agent to execute the right procedures when given a start, stop or monitor command.
The resource agent in this example will be OCF (Open Cluster Framework) standard. We will create a new OCF resource agent to manage the assign-ip.py service on both machines.
First, create the directory that will contain the resource agent. The directory name will be used by Pacemaker as an identifier for this custom agent.
Run the following on both machines:
Next, use floatip resource agent script and place it in the newly created directory, on both machines:
Now make the script executable with the following command on both machines:
chmod +x /usr/lib/ocf/resource.d/heficed/floatip
Next, register the resource agent within the cluster, using the PCS utility. The following command should be executed from one of the nodes:
pcs resource create FloatIP ocf:heficed:floatip
The resource should now be registered and active in the cluster. You can check the registered resources from any of the nodes with the pcs status command:
2 nodes and 1 resource configured
Online: [ primary secondary ]
Full list of resources:
FloatIP (ocf::heficed:floatip): Started primary
STEP 3. TEST THE SYSTEM
To test if the system is working, you can run floatip script in bash with command reporting:
bash -x /usr/lib/ocf/resource.d/heficed/floatip $command
$command is the option that is provided by the HA system. The script must work with these four commands:
start - start the resource.
stop - stop the resource.
monitor - monitor the health of a resource.
meta-data - provide information about this resource as an XML snippet.
To check the status code after the script completes, enter:
More information about OCF Resource can be found here.
If the script returns correct codes and doesn't show any errors, the system should work correctly. Otherwise, please debug as needed.
If you encounter any difficulties or have any further questions, feel free to contact our Customer Support Department by creating a Ticket in your Terminal or messaging us directly to email@example.com.