#!/bin/bash
while :
do
nginxpid=`ps -C nginx --no-header | wc -l`
if [ $nginxpid -eq 0 ];then
ulimit -SHn 65535 #在并发数很大的情况下,连接数过小会导致linux狂报错,所以直接在nginx启动前定义
/usr/local/nginx/sbin/nginx
sleep 5
nginxpid=`ps -C nginx --no-header | wc -l`
if [ $nginxpid -eq 0 ];then
/etc/init.d/keepalived stop
fi
fi
sleep 5
done相关说明可参考我发在组网频道的《企业级WEB的负载均衡高可用之LVS+Keepalived》一文。


