兩臺臺虛擬機MASTER 、BACKUPvim
1、關閉防火牆(全部虛擬機)
systemctl stop firewalld
setenforce 0服務器
2、在MASTER、BACKUPide
安裝keepalived
yum -y install keepalived ipvsadmrouter
修改配置文件
vim /etc/keepalived/keepalived.conf
############################
! Configuration File for keepalivedserver
global_defs {
notification_email {br/>acassen@firewall.loc
failover@firewall.locbr/>sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_strict #刪除此行
vrrp_skip_check_adv_addr
vrrp_garp_interval 0
vrrp_gna_interval 0
}ip
vrrp_instance VI_1 {
state MASTER #從服務器改成BACKUP
interface eno16777736 #改成本機網卡名
virtual_router_id 51
priority 100 #MASTER大於BACKUP
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.124.100 #設置VIP
}
}
########################################get
3、起啓動並檢測虛擬機
systemctl start keepalivedit
ip a
MASTER 存在 VIP BACKUP沒有VIPio
MASTER上關閉keepalived systemctl stop keepalivedip aMASTER 上沒有VIP BACKUP 上存在VIP