• keepalived 检测脑裂切换脚本


    #!/bin/bash
    
    count=0
    run1=`curl -I  192.168.30.12:8000 | grep "200 OK"  | wc -l`
    run2=`curl -I  192.168.30.12:8020 | grep "200 OK"  | wc -l`
    run3=`curl -I  192.168.30.12:8080 | grep "200 OK"  | wc -l`
    run=$[$run1 + $run2 + $run3]
    
    
    for (( k=0; k<10; k++ )) ; do
        /usr/bin/mysql -uroot -p'123456!' -h'192.168.30.21' -e "show databases;" > /dev/null
        if [ $? != 0 ];then
            echo "mysql faild !" >> /etc/keepalived/keepalived.log
            break
        fi
        if [ $run -ne 3 ] ; then
            sleep 2
            /etc/init.d/httpd start
            run1=`curl -I  192.168.30.12:8000 | grep "200 OK"  | wc -l`
            run2=`curl -I  192.168.30.12:8020 | grep "200 OK"  | wc -l`
            run3=`curl -I  192.168.30.12:8080 | grep "200 OK"  | wc -l`
            run=$[$run1 + $run2 + $run3]
            count=$(($count+1))
            echo "httpd start $count  faild !" >> /etc/keepalived/keepalived.log
        else
            #echo "httpd start $count  ok !" >> /etc/keepalived/keepalived.log
            break
        fi
        if [ "$count" == "9" ]; then
            /etc/init.d/keepalived stop
            echo “192.168.30.12 keepalived changed” | mail -s "keepalived changd" team_cloud_service@syberos.com
            echo "keepalived change !" >> /etc/keepalived/keepalived.log
            break
        fi
    done
  • 相关阅读:
    opentsdb安装部署
    python发送邮件(html)例子
    python查库写库例子
    获取rds的cpu和内存使用情况
    数据库损坏的情况下如何获取到dbid
    grafana安装升级部署
    Specified key was too long
    mysql动态执行sql批量删除数据
    kafka删除topics
    cratedb导入json文件
  • 原文地址:https://www.cnblogs.com/wangmo/p/9078209.html
Copyright © 2020-2023  润新知