说明:
1、keepalived 做为双机热备软件,是为lvs而生的扩展项目;
2、通过VRRP 协议实现。让其能够对后端有健康检查的功能。
安装:
yum -y install ipvsadm
yum -y install keepalived
启动keepalived服务
systemctl start keepalived.service
keepalived-master配置:
################################
vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
acassen@firewall.loc
}
notification_email_from root@localhost
router_id LVS_01
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state MASTER
interface ens192
virtual_router_id 10
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.100.1.101/24 dev ens192
}
}
virtual_server 10.100.1.101 443 {
delay_loop 3
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 10.100.1.21 443 {
weight 1
TCP_CHECK {
connect_port 443
connect_timeout 5
retry 3
delay_before_retry 3
}
}
real_server 10.100.1.22 443 {
weight 1
TCP_CHECK {
connect_port 443
connect_timeout 5
retry 3
delay_before_retry 3
}
}
}
#######################################
keepalived-slave配置:
state SLAVE
virtual_router_id 51
priority 100