Keeping alive to realize LVS load balancing high availability cluster

1. The preserved software is used to manage and monitor the status of each service node in LVS cluster system in the early stage;

2. In the later stage, VRRP is added to realize high availability. Therefore, it can provide high availability for lvs load balancing and other services..

Experiment image: Centos 8.1.1911

Sketch: (to be filled)

1. Two real server installation configurations

No problem testing on the maintained master.

[root@HA1 ~]# curl http://192.168.94.140
this is real 1 server
[root@HA1 ~]# curl http://192.168.94.141
this is real 2 server
[root@HA1 ~]#

2. Install keepalived, ipvsadm

yum install ipvsadm keepalived -y

Use keepalived to add real server.

The configuration file is under / etc/keepalived

[root@HA1 keepalived]# pwd
/etc/keepalived
[root@HA1 keepalived]# ls
keepalived.conf
[root@HA1 keepalived]# cp keepalived.conf keepalived.conf.bak
[root@HA1 keepalived]# echo "" > keepalived.conf
[root@HA1 keepalived]#

3. keepalived file configuration

MASTER

! Configuration File for keepalived
  # overall situation
global_defs {
   notification_email {
         root@localhost
   }
   notification_email_from keepalived@server.com
   smtp_connect_timeout 3
   smtp_server 127.0.0.1
   router_id LVS_DEVEL
}


# A maintained server, with MASTER as the main provider
vrrp_instance VI_1 {
    interface ens33
    state MASTER
    priority 101
    virtual_router_id 51
    garp_master_delay 1

    authentication {
        auth_type PASS
        auth_pass password
    }
	# VIP address
    virtual_ipaddress {
        192.168.94.200 dev ens33 label ens33:0
    }
}

# VIP is associated with two real server s
virtual_server 192.168.94.200 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 50
    protocol TCP
#	Both real server s fail. Address of service provided
    sorry_server 192.168.94.138 80

# Define real server 1
    real_server 192.168.94.140 80 {
        weight 1
	# real server survival detection, detection of url code
        HTTP_GET {
            url {
              path /
              status_code 200
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
# Define real server 2
    real_server 192.168.94.141 80 {
        weight 1
        HTTP_GET {
            url {
              path /
              status_code 200
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

Copy configuration file to HA2

BACKUP

! Configuration File for keepalived
  # overall situation
global_defs {
   notification_email {
         root@localhost
   }
   notification_email_from keepalived@server.com
   smtp_connect_timeout 3
   smtp_server 127.0.0.1
   router_id LVS_DEVEL
}


# A maintained server, with MASTER as the main provider
vrrp_instance VI_1 {
    interface ens33
    state BACKUP
    priority 100
    virtual_router_id 51
    garp_master_delay 1

    authentication {
        auth_type PASS
        auth_pass password
    }
	# VIP address
    virtual_ipaddress {
        192.168.94.200 dev ens33 label ens33:0
    }
}

# VIP is associated with two real server s
virtual_server 192.168.94.200 80 {
    delay_loop 6
    lb_algo rr
    lb_kind DR
    persistence_timeout 50
    protocol TCP
#	Both real server s fail. Address of service provided
    sorry_server 192.168.94.139 80

# Define real server 1
    real_server 192.168.94.140 80 {
        weight 1
	# real server survival detection, detection of url code
        HTTP_GET {
            url {
              path /
              status_code 200
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
# Define real server 2
    real_server 192.168.94.141 80 {
        weight 1
        HTTP_GET {
            url {
              path /
              status_code 200
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

1. High availability

Both nodes (MASTER, BACKUP) start the service.

View address ifconfig – a

VIP will only start on MASTER. When MASTER service fails, BACKUP will provide service.

2. real server resource management

After the real server node fails, preserved will be automatically deleted in ipvs. It will be added again after it goes online.

There may be something wrong with my configuration file. It's strange when I test it. I'll check it sometime.


There is always one on the way to study and keep fit

Tags: Linux curl CentOS yum

Posted on Thu, 04 Jun 2020 09:01:04 -0700 by hailam