keepalived+httpd 高可用

httpd_check.sh

===================================================

#!/bin/bash
num=`ps -ef | grep httpd | wc -l`
if [ $num -eq 1 ];then
systemctl start httpd
sleep 3
if [ $num -eq 1 ];then
killall keepalived
fi
fi

===================================

安装killall命令  yum -y install psmisc

keepalived配置文件

======================================================

! Configuration File for keepalived

global_defs {
router_id httpd_01
}
vrrp_script chk_nginx {
script "/root/httpd_check.sh"
interval 2
weight -20
}

vrrp_instance VI_1 {
state MASTER
interface bond0
virtual_router_id 51
mcast_src_ip 192.168.174.20
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
chk_nginx
}
virtual_ipaddress {
192.168.174.111
}
}

=============================================

原文地址:https://www.cnblogs.com/fang12311/p/14097864.html