The cart is empty

In today's digital landscape, high availability of services is a critical factor in maintaining customer satisfaction and uninterrupted business operations. One technique to achieve high availability is the implementation of IP address failover, which automatically redirects network traffic to a backup system in case of primary system failure. This article focuses on the configuration and management of IP address failover using the Keepalived tool on the CentOS operating system.

Introduction to Keepalived

Keepalived is software that provides a simple and effective solution for configuring failover and load balancing in Linux systems. It utilizes the Virtual Router Redundancy Protocol (VRRP) to automatically assign virtual IP addresses to the active server in a cluster, ensuring high availability of services.

Installation of Keepalived on CentOS

Before beginning the configuration, it is necessary to install Keepalived on all servers where failover will be performed. Installation can be done using the following command in the terminal:

sudo yum install keepalived

Configuration of Keepalived for IP address failover

The Keepalived configuration file is typically located at /etc/keepalived/keepalived.conf. This file needs to be edited to match our requirements for failover and high availability.

The basic configuration includes defining the vrrp_instance, which specifies the group of servers (nodes) and the virtual IP address to be assigned to the active server. A configuration example for the primary server may look like this:

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass secret
    }
    virtual_ipaddress {
        192.168.1.10
    }
}

And for the backup server:

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 50
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass secret
    }
    virtual_ipaddress {
        192.168.1.10
    }
}

Differences between configurations for primary and backup servers lie in the state and priority values. state determines the initial state of the server in the VRRP group. priority sets the server's priority; a higher value means a higher likelihood of the server being selected as MASTER.

Starting and Testing Keepalived

After completing the configuration on all servers, Keepalived can be started using the following command:

sudo systemctl start keepalived

To verify proper functionality, the service on the primary server can be turned off, and observation can be made to ensure that the backup server takes over its functions without service interruption. Keepalived logs, typically located at /var/log/messages, provide information about the status of the VRRP instance and server switchover.

Monitoring and Management of Keepalived

To ensure uninterrupted operation and quick response to any issues, it is essential to implement effective monitoring of services and Keepalived instances. Several tools and approaches can help identify and address high availability issues:

  1. Logging and Auditing: Keepalived logs to the system log, usually to /var/log/messages on CentOS. These logs should be regularly checked to identify warning and error messages related to the failover process.

  2. Monitoring Tools: Active monitoring of service and Keepalived instance status can be achieved using tools such as Nagios, Zabbix, or Prometheus. These tools allow defining threshold values for various metrics and generating alerts if these values are exceeded.

  3. Configuration Testing and Validation: Regular testing of failover mechanisms is crucial to ensure their reliability in a production environment. This includes simulating primary server failures and verifying that the backup server takes over its functions without service interruption.

  4. Optimization and Maintenance: As network environments and service requirements may change over time, it is essential to regularly review and optimize Keepalived configuration. This includes software updates, priority adjustments, and testing of new configurations to ensure optimal performance and availability.

Best Practices for Using Keepalived for IP Address Failover

  • Security: Ensure that communication between servers using VRRP is secure to prevent potential attacks and misuse.
  • Documentation and Procedures: Maintain detailed documentation of your Keepalived configuration and create standardized procedures for incident resolution and recovery.
  • Multi-level Redundancy: In addition to IP address failover, consider implementing additional levels of redundancy, such as power redundancy, network connectivity, and hardware redundancy, to maximize service availability.

The implementation and management of IP address failover using Keepalived on CentOS is an effective strategy for ensuring high availability of services. Through careful configuration, regular monitoring, and testing, you can minimize downtime and secure uninterrupted operation of your critical services.