364.4 Network High Availability (weight: 5)

a camel and its handler ready for transport

Tech Tutorial: 364.4 Network High Availability (weight: 5) #

Introduction #

In the world of networking, high availability (HA) is essential to ensure continuous service operation during various failure scenarios. Network High Availability involves the implementation of methodologies and systems that ensure network reliability, uptime, and resilience. This tutorial aims to cover the critical aspects and commands necessary to configure high availability for networks on Linux systems.

Key Knowledge Areas: #

  • Redundancy
  • Failover
  • Load balancing
  • High Availability configurations

Utilities: #

  • Keepalived
  • HAProxy
  • Pacemaker
  • Corosync

Step-by-Step Guide #

1. Configuring Redundancy with Keepalived #

Keepalived provides simple and robust facilities for load balancing and high availability to Linux systems and Linux-based infrastructures. The configuration of keepalived involves creating a keepalived.conf file which typically resides in /etc/keepalived/.

Example: Basic Keepalived Setup #

First, install Keepalived:

sudo apt-get install keepalived

Create or modify the /etc/keepalived/keepalived.conf:

global_defs {
   notification_email {
     admin@example.com
   }
   router_id LVS_DEMO
}

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

Explanation:

  • global_defs: Global settings for notifications and identification.
  • vrrp_instance: Defines a VRRP instance.
  • state: Could be MASTER or BACKUP.
  • interface: Network interface to listen on.
  • virtual_router_id: A unique ID for the VRRP instance.
  • priority: Determines the role of MASTER or BACKUP.
  • virtual_ipaddress: The IP address shared among the nodes.

Reload the keepalived configuration:

sudo systemctl restart keepalived

Check the status:

systemctl status keepalived

2. Load Balancing with HAProxy #

HAProxy is widely used for providing high availability and load balancing solutions to enhance the reliability of server environments.

Example: Basic HAProxy Configuration #

Install HAProxy:

sudo apt-get install haproxy

Configure HAProxy by editing /etc/haproxy/haproxy.cfg:

global
    log /dev/log local0
    maxconn 4000
    user haproxy
    group haproxy

defaults
    mode http
    log global
    option httplog
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms

frontend http_front
    bind *:80
    stats uri /haproxy?stats
    default_backend http_back

backend http_back
    balance roundrobin
    server server1 192.168.1.101:80 check
    server server2 192.168.1.102:80 check

Explanation:

  • global: Sets global settings.
  • defaults: Sets defaults for all proxies.
  • frontend: Defines listening ports and other front-end settings.
  • backend: Configures backend servers and load balancing method.

Reload HAProxy configuration:

sudo systemctl restart haproxy

3. High Availability with Pacemaker and Corosync #

Pacemaker and Corosync are commonly used together to create a high availability cluster.

Installing and Configuring Corosync #

Install Corosync:

sudo apt-get install corosync

Configure Corosync by editing /etc/corosync/corosync.conf:

totem {
    version: 2
    cluster_name: cluster_name
    transport: udpu
    interface {
        ringnumber: 0
        bindnetaddr: 192.168.1.0
        mcastaddr: 239.255.1.1
        mcastport: 5405
    }
}

nodelist {
    node {
        ring0_addr: node1
        nodeid: 1
    }
    node {
        ring0_addr: node2
        nodeid: 2
    }
}

quorum {
    provider: corosync_votequorum
}

Start and enable Corosync:

sudo systemctl start corosync
sudo systemctl enable corosync

Installing and Configuring Pacemaker #

Install Pacemaker:

sudo apt-get install pacemaker

Integrate Pacemaker with Corosync:

sudo pcs cluster setup --name cluster_name node1 node2
sudo pcs cluster start --all

Configure a simple resource with Pacemaker:

sudo pcs resource create virtual_ip ocf:heartbeat:IPaddr2 ip=192.168.1.100 cidr_netmask=24 op monitor interval=30s

Check cluster status:

sudo pcs status

Conclusion #

By following the steps outlined in this tutorial, you will be able to configure network high availability using Keepalived, HAProxy, and the combination of Pacemaker and Corosync. These tools are essential for creating resilient networks that can maintain service continuity even during failures. Remember, the key to successful network high availability lies in thorough testing and continuous monitoring of the configured systems.

This tutorial aims to provide a foundational understanding and practical examples to help prepare you for implementing network high availability as covered under exam objective 364.4.