yum install keepalived -y
修改/etc/keepalived.conf配置文件,达到高可用状态
vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id MASTER #主写MASTER,备写BACKUP
}
vrrp_instance VI_1 {
state MASTER #主写MASTER,备写BACKUP
interface eth0 #本机的有效网卡
virtual_router_id 51 #高可用集群组里的id
priority 100 #优先级权值,主的值比备的要高
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.108.200 #虚拟VIP
}
}
systemctl start keepalived
systemctl enable keepalived