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
}
}

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

posted @ 2020-12-07 16:38  fang12311  阅读(91)  评论(0编辑  收藏  举报