zoukankan      html  css  js  c++  java
  • keppalived 高可用备 脚本

    #!/bin/bash
    yum -y install keepalived >/dev/null
    touch /opt/kill.sh
    cat >/opt/kill.sh<<EOF
    #!/bin/bash
    systemctl stop keepalived
    EOF
    same=`grep -f /opt/keepalived.conf /etc/keepalived/keepalived.conf|wc -l`
    diferent=`cat /etc/keepalived/keepalived.conf|wc -l`
    if [ $same -eq $diferent ];then
    cp /opt/keepalived.conf /etc/keepalived/keepalived.conf
    fi
    systemctl start keepalived
    if [ $? -eq 0 ];then
    systemctl stop keepalived
    systemctl start keepalived
    fi

    ~

    配置文件展示

    [root@ localhost opt]# vim keepalived.conf 
    
       router_id LVS_DEVEL
       vrrp_skip_check_adv_addr
       vrrp_strict
       vrrp_garp_interval 0
       vrrp_gna_interval 0
    }
    
    vrrp_instance VI_1 {
        state BACKUP
        interface ens33
        virtual_router_id 51
        priority 50
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
            10.0.0.81
        }
    }
    
    virtual_server 10.0.0.81 80 {
        delay_loop 6
        persistence_timeout 50
        protocol TCP
    
        real_server 10.0.0.43 80 {
            weight 1
            notify_down /opt/kill.sh
            TCP_CHECK {
                                 
                connect_timeout 3
                connect_port 80
                nb_get_retry 3
                delay_before_retry 3
            }
        }
    }
    

      

      

  • 相关阅读:
    最短路径的三种实现方法
    c/c++小知识
    c++ char * const p问题
    C++ typedef 四个用途
    [转]c++面向对象基础
    [转]C++中引用(&)的用法和应用实例
    表情包。
    linux基础学习
    redis缓存在项目中的使用
    关于redis
  • 原文地址:https://www.cnblogs.com/gaiting/p/12203222.html
Copyright © 2011-2022 走看看