yum install keepalived
编辑keepalived.conf:
vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id bj_ifc_ngix
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 90
advert_int 1
}
authentication {
auth_type PASS
auth_pass 314159
}
virtual_ipaddress {
192.168.1.253
}
state 2个都写成backup,让2台机器通过priority的优先级去抢主 ,优先级高的是主,最下面的IP我设定的是和eth0IP一个网段的,通过service keepalived start
启动服务,直接ping 253,如果通,那证明虚拟IP成功.