zoukankan      html  css  js  c++  java
  • keepalived 高可用主 脚本

    #!/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_master.conf /etc/keepalived/keepalived.conf|wc -l`
    diferent=`cat /etc/keepalived/keepalived.conf|wc -l`
    if [ $same -eq  $diferent ];then
            cp /opt/keepalived_master.conf /etc/keepalived/keepalived.conf
    fi
    systemctl start keepalived
    if [ $? -eq 0 ];then
            systemctl stop keepalived
            systemctl start keepalived
    fi  

    配置文件
    [root@ localhost opt]# cat keepalived_master.conf 
    ! Configuration File for keepalived
    
    global_defs {
       notification_email {
         acassen@firewall.loc
         failover@firewall.loc
         sysadmin@firewall.loc
       }
       notification_email_from Alexandre.Cassen@firewall.loc
       smtp_server 192.168.200.1
       smtp_connect_timeout 30
       router_id LVS_DEVEL
       vrrp_skip_check_adv_addr
       vrrp_strict
       vrrp_garp_interval 0
       vrrp_gna_interval 0
    }
    
    vrrp_instance VI_1 {
        state MASTER
        interface ens33
        virtual_router_id 51
        priority 100
        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.42 80 {
            weight 1
    	notify_down /opt/kill.sh
            TCP_CHECK {
                connect_timeout 3
                connect_port 80
                nb_get_retry 3
                delay_before_retry 3
            }
        }
    }
    

      

  • 相关阅读:
    2017-10-11seowhy记录
    2017.8.23创业项目方向
    西安项目分析
    创业方法
    做seowhy官网需要三个人
    2017.8.2 高级长尾编辑技巧
    Golang 任务队列策略 -- 读《JOB QUEUES IN GO》
    Go 到底有没有引用传参(对比 C++ )
    使用xorm工具,根据数据库自动生成 go 代码
    golang的Channel
  • 原文地址:https://www.cnblogs.com/gaiting/p/12203235.html
Copyright © 2011-2022 走看看