#!/bin/bash #auto check nginx vip #by author andy VIP="10.0.0.88" IP="ifconfig | sed -n '2p'|awk -F' ' '{print $2}'" NUM="$(ps -ef | grep nginx | grep -vcE "grep|check")" ping -c 2 $VIP >>/dev/null if [ $? -ne 0 ]; then if [ $NUM -ne 0 ]; then cd /etc/sysconfig/network-scripts/ cp ifcfg-eth0 ifcfg-eth0:1 cat >ifcfg-eth0:1<<EOF DEVICE=eth0 ONBOOT=yes BOOTPROTO=static TYPE=Ethernet NAME=eth0 IPADDR=$VIP NETMASK=255.255.255.0 GATEWAY=10.0.0.2 DNS1= DNS2= EOF ifup eth0:1 ip addr else ifdown eth0:1 fi else if [ $NUM -eq 0 ]; then ifdown eth0:1 fi fi
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
负载均衡 nginx+ keepalived +vip
负载均衡 nginx+ keepalived +vip
nginx 负载均衡 运维 Backup 重启