安装过程很简单 基本也不需要什么参数 就不列举了
主配置文件 如下 more /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id nginx-proxy-ha
}
vrrp_script check_nginx {
script "/etc/keepalived/check_nginx.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 200
advert_int 1
authentication {
auth_type PASS
auth_pass 1234
}
track_interface {
eth0
}
track_script {
check_nginx
}
virtual_ipaddress {
192.168.153.100
}
}
从配置文件如下 就更改 state 和priority 两项
! Configuration File for keepalived
global_defs {
router_id nginx-proxy-ha
}
vrrp_script check_nginx {
script "/etc/keepalived/check_nginx.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 180
advert_int 1
authentication {
auth_type PASS
auth_pass 1234
}
track_interface {
eth0
}
track_script {
check_nginx
}
virtual_ipaddress {
192.168.153.100
}
}
检测脚本如下 cat /etc/keepalived/check_nginx.sh
#!/bin/bash
if [ "$(ps -ef | grep "nginx: master process"| grep -v grep )" == "" ]
then
killall -9 keepalived
fi
阅读(1245) | 评论(0) | 转发(0) |