共计 1575 个字符,预计需要花费 4 分钟才能阅读完成。
HAproxy 重启动,检查文件的脚本
#!/bin/bash
### BEGIN INIT INFO
#Manage the HAProxy
### END INIT INFO
bin=/usr/local/haproxy/sbin/haproxy
config=/usr/local/haproxy/conf/haproxy.cfg
pid=/usr/local/haproxy/haproxy.pid
opts=” -f ${config} -p ${pid} -D -V ”
sleep_time=1
start() {
echo -e “Starting HAProxy……”
${bin} ${opts}
if [“$?” != “0”] ; then
sleep ${sleep_time}
echo ” failed”
exit 1
else
sleep ${sleep_time}
echo ” done”
fi
}
stop() {
if [! -e ${pid} ] ; then
echo -e “HAProxy is not running”
exit 0
fi
echo -e “Shutting down HAProxy……”
kill $(cat ${pid})
if [-e ${pid} ] ; then
rm -f ${pid}
fi
if [“$?” != “0”] ; then
sleep ${sleep_time}
echo ” failed”
exit 1
else
sleep ${sleep_time}
echo ” done”
fi
}
reload(){
${bin} -f ${config} -st $(cat ${pid})
echo -e “HAProxy is reload……”
}
checkconfig(){
${bin} -c -f ${config}
echo -e “haproxy file is ok”
}
restart() {
stop
start
}
case “$1” in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
checkconfig)
checkconfig
;;
*)
echo “Usage: $0 {start|stop|restart|reload|checkconfig}”
exit 1
;;
esac
HAproxy 的详细介绍 :请点这里
HAproxy 的下载地址 :请点这里
推荐阅读:
Haproxy+Keepalived 搭建 Weblogic 高可用负载均衡集群 http://www.linuxidc.com/Linux/2013-09/89732.htm
Keepalived+HAProxy 配置高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/56748.htm
CentOS 6.3 下 Haproxy+Keepalived+Apache 配置笔记 http://www.linuxidc.com/Linux/2013-06/85598.htm
Haproxy + KeepAlived 实现 WEB 群集 on CentOS 6 http://www.linuxidc.com/Linux/2012-03/55672.htm
Haproxy+Keepalived 构建高可用负载均衡 http://www.linuxidc.com/Linux/2012-03/55880.htm