环境准备 test1 eth1:18.1.30.58 VIP:18.1.30.30 MASTER
test2 eth0: 18.1.30.59 BACKUP
test1的keepalived的配置
[iyunv@test1 ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id HAWEB
}
vrrp_sync_group VGM {
group {
VI_HA
}
}
vrrp_instance VI_HA {
state MASTER
interface eth1
virtual_router_id 51
priority 100
advert_int 5
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
18.1.30.58/24 dev eth1
}
}
[iyunv@test1 ~]# scp /etc/keepalived/keepalived.conf root@18.1.30.69:/etc/keepalived
test2的keepalived配置
global_defs {
router_id HAWEB
}
vrrp_sync_group VGM {
group {
VI_HA
}
}
vrrp_instance VI_HA {
state BACKUP
interface eth1
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
18.1.30.30/24 dev eth1
}
}
测试 [iyunv@test1 ~]# cat /var/www/html/index.html
test1
[iyunv@test2 ~]# cat /var/www/html/index.html
test2
[iyunv@test1 ~]# service keepalived stop
Stopping keepalived: [ OK ]
|