Role | IP | 备注 |
---|---|---|
master1 | 172.19.1.21 | |
master2 | 172.19.1.22 | |
master3 | 172.19.1.23 | |
VIP1 | 172.19.1.8 | |
VIP2 | 172.19.1.9 | |
VIP3 | 172.19.1.10 |
1、apt update
2、apt install -y keepalived
3、dpkg -L keepalived
4、cp /usr/share/doc/keepalived/samples/keepalived.conf.vrrp /etc/keepalived/keepalived.conf
global_defs {
notification_email {
acassen
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER #不同角色设置不同值 MASTER 和 BACKUP
interface ens32 #指定网卡设备名
garp_master_delay 10
smtp_alert
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.19.1.8 dev ens32 label ens32:0
172.19.1.9 dev ens32 label ens32:1
172.19.1.10 dev ens32 label ens32:2
}
}
5、 systemctl enable --now keepalived
6、ip a
master1 停用网卡看出vip是否飘走
ip link set dev ens32 down (注意如果远程连接使用的是这个网卡设置会断开的,将无法远程管理)
7、在其他查看ip地址是否有vip