keepalived脚本

#!/bin/sh   
#   
# keepalived   High Availability monitor built upon LVS and VRRP   
#   
# chkconfig:   - 86 14   
# description: Robust keepalive facility to the Linux Virtual Server project \   
#              with multilayer TCP/IP stack checks.   
     
### BEGIN INIT INFO   
# Provides: keepalived   
# Required-Start: $local_fs $network $named $syslog   
# Required-Stop: $local_fs $network $named $syslog   
# Should-Start: smtpdaemon httpd   
# Should-Stop: smtpdaemon httpd   
# Default-Start:    
# Default-Stop: 0 1 2 3 4 5 6   
# Short-Description: High Availability monitor built upon LVS and VRRP   
# Description:       Robust keepalive facility to the Linux Virtual Server   
#                    project with multilayer TCP/IP stack checks.   
### END INIT INFO   
     
# Source function library.   
. /etc/rc.d/init.d/functions   
  
exec="/usr/local/sbin/keepalived"  
prog="keepalived"  
config="/etc/keepalived/keepalived.conf"  
     
[ -e /usr/local/etc/sysconfig/$prog ] &&  /usr/local/etc/sysconfig/$prog   
  
lockfile=/var/lock/subsys/keepalived   
  
start() {   
    [ -x $exec ] || exit 5   
    [ -e $config ] || exit 6   
    echo -n $"Starting $prog: "   
    daemon $exec $KEEPALIVED_OPTIONS  
    retval=$?   
    echo   
    [ $retval -eq 0 ] && touch $lockfile   
    return $retval   
}   
     
stop() {   
    echo -n $"Stopping $prog: "   
    killproc $prog   
    retval=$?   
    echo   
    [ $retval -eq 0 ] && rm -f $lockfile   
    return $retval   
}   
     
restart() {   
    stop   
    start   
}   
     
reload() {   
    echo -n $"Reloading $prog: "   
    killproc $prog -1   
    retval=$?   
    echo   
    return $retval   
}   
     
force_reload() {   
    restart   
}   
     
rh_status() {   
    status $prog   
}   
     
rh_status_q() {   
    rh_status &>/dev/null   
}   
     
     
case "$1" in   
    start)   
        rh_status_q && exit 0   
        $1   
        ;;   
    stop)   
        rh_status_q || exit 0   
        $1   
        ;;   
    restart)   
        $1   
        ;;   
    reload)   
        rh_status_q || exit 7   
        $1   
        ;;   
    force-reload)   
        force_reload   
        ;;   
    status)   
        rh_status   
        ;;   
    condrestart|try-restart)   
        rh_status_q || exit 0   
        restart   
        ;;   
    *)   
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"   
        exit 2   
esac   
exit $?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值