keepalive 配置

此生再无相见时 提交于 2020-08-11 12:24:21

vi /etc/keepalived/keepalived.conf
 

! Configuration File for keepalived

global_defs {
#   notification_email {
#     lipengfei@topnet.net.cn
#   }
#   notification_email_from  lipengfei@topnet.net.cn
#   smtp_server smtp.exmail.qq.com
#   smtp_connect_timeout 30
    router_id master
#   vrrp_skip_check_adv_addr
#   vrrp_strict
#   vrrp_garp_interval 0
#   vrrp_gna_interval 0
}

vrrp_script chk_mysql {  #定义脚本并设置规则
          script "</dev/tcp/127.0.0.1/3306"
          interval 1
          weight -2
          fall 3
          rise 5
          timeout 5
}

vrrp_instance VI_1 {
    state MASTER
    interface ens192
    virtual_router_id 51
    priority 100
#    nopreempt
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.3.247
    }
    # 单播模式,需事先关闭全局 vrrp_strict 选项,否则报错
    unicast_src_ip  192.168.3.211   # 本机IP
    unicast_peer {
        192.168.3.212       # 其他keepalived主机IP
    }

    track_script {
      chk_mysql
    }
    notify_master /etc/keepalived/sendmail.sh
}


#vrrp_script check_apiserver {
# script "/etc/keepalived/check-apiserver.sh"
# interval 3
# weight -2
#}

#vrrp_instance VI-kube-master {
#   state MASTER
#   interface ens192
#   virtual_router_id 68
#   priority 100
#   dont_track_primary
#   advert_int 3
#   virtual_ipaddress {
#     192.168.3.250
#   }
#   track_script {
#       check_apiserver
#   }
#}

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!