查看是否可以YUM安装
yum list keepalived
YUM
安装
yum install -y keepalived
查看IP和网卡
ifconfig 例如下图红框部分即为IP和网卡
编辑配置文件
vi /etc/
keepalived/
keepalived.conf
主服务器配置:
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass RedisKeepalivedPass2019
}
virtual_ipaddress {
192.168.35.139
}
}
备服务器配置:
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass RedisKeepalivedPass2019
}
virtual_ipaddress {
192.168.35.139
}
}
设置开机自启动
systemctl enable keepalived
启动
systemctl start keepalived
查看启动结果
ps aux | grep keepalived
查看VIP
ip addr show