2024-07-08
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
LVS keepalived
keepalived background
Auxiliary tools for LVS, mainly providing failover and health checks.
Working scenario: hot standby of the scheduler, health check of the node server and failover (deletion of entries).
The VRRP protocol is used to achieve high availability.
keepalived deployment
Topology
High availability is achieved between the two schedulers, and the health status of the web servers is checked, and load balancing is performed between the web servers.
Configuration of two schedulers
Prelude
Add or disable the firewall, and disable the kernel security mechanism
Turn off NetworkManager
If this service is not closed, the drifting IP cannot drift
Install keepalived and configure
After installation, set it to start automatically
systemctl disable keepalived
Copy the configuration file: /etc/keepalived/keepalived
Configuration file details
Global Configuration Section
global_defs {
notification_email {
This module indicates that an email notification needs to be sent when a keep switch operation occurs, and to which email addresses it is sent
Specific email addresses, one per line
}
notification_email_from [email protected]
This line defines who sends the alert email (Sender)
smtp_server 192.168.200.1
It means that you can use the mail service of that server to send mails. Usually you can use 127.0.0.1, which means that the local machine provides the service.
smtp_connect_timeout 30
Timeout for connecting to stmp service
router_id LVS_DEVEL
Machine identification: Identification of different servers, which does not affect the actual operation of the service and allows for quick location of mail services
vrrp_skip_check_adv_addr
No check is done on the master's declared address, and keepalived is run loosely
vrrp_strict
Enabling this option will not allow unicast communication unless the network is properly configured.
vrrp_garp_interval 0
Periodically announce IP address ownership. When set to 0, it will only be announced after switching.
vrrp_gna_interval 0
}
VRRP instance section
vrrp_instance VI_1 {
Instance name. A server can have multiple instances (application scenarios) which will be described later.
state MASTER
Determine the initial status of the role
init position in the vrrp election cycle
interface eth0
The network card that carries the VIP is based on your own
virtual_router_id 51
Each instance must use the same VRID to join the same hot standby group.
priority 100
Because VRRP uses priority to elect the master based on the range (0~255), 0 is reserved, 255 (IP address owner)
advert_int 1
The interval, in seconds, between master announcement messages (to tell other backups) that the master is still alive.
authentication {
When other instances want to join the hot standby group, password authentication is required.
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
Virtual VIP address: Each virtual VIP represents a cluster
192.168.200.16
192.168.200.17
192.168.200.18
}
}
Virtual Server Section
virtual_server 192.168.200.100 443 {
Corresponding to the VIP in the instance, it is the beginning of a cluster
delay_loop 6
Health check interval
lb_algo rr
Scheduling Algorithm
rr|wrr|lc|wlc|lblc|sh|dh