安装keepalived
1 | yum install -y keepalived |
keepalived配置文件(主)
|
keepalived配置文件(从)
|
nginx_check.sh
1 2 3 4 5 6 7 8 9 10 | #!/bin/bash counter=$( ps -C nginx --no-heading| wc -l) if [ "${counter}" = "0" ]; then /server/nginx/sbin/nginx #如果nginx没有启动就先启动nginx sleep 2 counter=$( ps -C nginx --no-heading| wc -l) if [ "${counter}" = "0" ]; then service keepalived stop #如果nginx还是没有启动就关闭keepalived把虚拟IP让出去(注意不同操作系统的命令有所不同) fi fi |