zoukankan      html  css  js  c++  java
  • Keepalived实战(3)

    一、环境

    如上图所示:

    keepalived的mater为proxy-master,keepalived的slave为proxy-slave。

    要求:当mater出现问题时,主动切换到slave上。这里只是进行简单的主从切换展示,后续会有专门一节将zabbix proxy高可用方式。

    二、配置文件

    1、master的配置文件

    cat keepalived.conf
    ! Configuration File for keepalived

    global_defs {
    notification_email {
    xuequn@kingsoft.com
    }
    notification_email_from zabbix@kingsoft.com
    smtp_server 127.0.0.1
    smtp_connect_timeout 30
    router_id LVS_DEVEL
    }

    vrrp_script chk_zabbix_web {

    script "killall -0 zabbix_proxy"
    interval 10
    weight 20

    }


    vrrp_instance VI_ZBX_WEB {
    state BACKUP  #注意,这里因为考虑到切换成slave后我不再切回来,所以也配置成backup,且为nopreempt模式
    nopreempt #when myself is master,set this option.
    interface eth0
    virtual_router_id 160
    priority 100
    advert_int 1
    mcast_src_ip 192.168.1.102
    authentication {
    auth_type PASS
    auth_pass ZabbixServer
    }
    track_script {

    chk_zabbix_web

    }
    virtual_ipaddress {
    192.168.1.100
    }

    #notify_master "/etc/keepalived/change_to_master.sh"
    notify_backup "/etc/keepalived/change_to_backup.sh"   #切换为backup后,执行的脚本
    }

    slave上的配置:

    cat keepalived.conf
    ! Configuration File for keepalived

    global_defs {
    notification_email {
    xuequn@kingsoft.com
    }
    notification_email_from zabbix@kingsoft.com
    smtp_server 127.0.0.1
    smtp_connect_timeout 30
    router_id LVS_DEVEL
    }


    vrrp_script chk_zabbix_web {

    script "killall -0 zabbix_agentd"
    interval 10
    weight 20


    }


    vrrp_instance VI_ZBX_WEB {
    state BACKUP
    #nopreempt #when myself is master,set this option.
    interface eth1
    virtual_router_id 160
    priority 90
    advert_int 1
    mcast_src_ip 192.168.1.101
    authentication {
    auth_type PASS
    auth_pass ZabbixServer
    }
    track_script {

    chk_zabbix_web

    }
    virtual_ipaddress {
    192.168.1.100

    }

    notify_master "/etc/keepalived/change_to_master.sh"  #切换为master后,执行的脚本
    #notify_backup "/etc/keepalived/change_to_backup.sh"
    }

    三、启动并测试

    1、正常启动

    2、故障切换

    3、nopreempt测试

    PS:本文纯属记录个人实践经历,如有问题,可随时联系我。QQ505711559

  • 相关阅读:
    MV*模式的个人理解
    Unlink of file '.git/objects/pack/pack-***.pack' failed. Should I try again? (y/n) (转)
    不定宽高元素的水平垂直居中
    判断是否在微信浏览器中
    HTML5实战与剖析之触摸事件(touchstart、touchmove和touchend)(转)
    清除inline-block元素间距
    rs485多主
    基于状态机的单片机按键短按长按功能的实现
    深入理解FIFO(包含有FIFO深度的解释)——转载
    传递指针的指针(错误的例子)
  • 原文地址:https://www.cnblogs.com/skyflask/p/6970110.html
Copyright © 2011-2022 走看看