二、Master配置
Master:
!要使用ha功能,不能使用vrrp_sync_group
!vrrp_sync_group VG1 {
! group {
! VI_1
! }
!}
! script "/usr/local/keepalived/sbin/nginx_sh.sh"
script "killall -0 httpd"
interval 2
weight 4
}
vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 100
authentication {
auth_type PASS
auth_pass 111
}
track_script {
chk_http_port
}
virtual_ipaddress {
192.168.8.20/24 dev eth0
192.168.8.30/24 dev eth0
}
}
!vrrp_sync_group VG1 {
! group {
! VI_1
! }
!}
!要使用ha功能,不能使用vrrp_sync_group
vrrp_script chk_http_port {
! script "/usr/local/keepalived/sbin/nginx_sh.sh"
script "killall -0 httpd"
interval 2
weight 4
}
vrrp_instance VI_1 {
interface eth0
state BACKUP
virtual_router_id 51
priority 98
authentication {
auth_type PASS
auth_pass 111
}
track_script {
chk_http_port
}
virtual_ipaddress {
192.168.8.20/24 dev eth0
192.168.8.30/24 dev eth0
}
}
#keepalived 启动方式放在脚本里
[root@ora2 keepalived]# cat /usr/bin/keepalived_start
/usr/local/keepalived/sbin/keepalived -D -f /usr/local/keepalived/etc/keepalived/keepalived.conf