码迷,mamicode.com
首页 > 其他好文 > 详细

keepalived费抢占式高可用

时间:2017-02-14 23:03:04      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:keep   alived费   抢占式高可用   

master: 192.168.108.18
slave: 192.168.108.19
vip: 192.168.108.17

master: keepalived.conf
global_defs {
    notification_email {
            ****@****.com
    }

    notification_email.from keepalived@localhost.com
    smtp_server ****
    smtp_connect_timeout 30
    route_id LVS_DEVEL
}

vrrp_script chk_nginx_port {
    script "/etc/keepalived/nginx_pid.sh"
    interval 2
}

vrrp_instance VI_1 {
    state BACKUP
    nopreempt
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }

    track_script {
        chk_nginx_port
    }

    virtual_ipaddress {
        192.168.108.17
    }
}

slave: keepalived.conf
global_defs {
    notification_email {
            ****@****.com
    }

    notification_email.from keepalived@localhost.com
    smtp_server ****
    smtp_connect_timeout 30
    route_id LVS_DEVEL
}

vrrp_script chk_nginx_port {
    script "/etc/keepalived/nginx_pid.sh"
    interval 2
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 90
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }

    track_script {
        chk_nginx_port
    }

    virtual_ipaddress {
        192.168.108.17
    }
}

/etc/keepalived/nginx_pid.sh
#!/bin/bash

nginx_pid=`ps aux | grep nginx | grep -v grep | grep master | awk ‘{print $2}‘`
if [[ $nginx_pid != "" ]]
then
    exit 0
else
    exit 1
fi


本文出自 “ubuntu” 博客,请务必保留此出处http://thankinglove.blog.51cto.com/2311485/1897515

keepalived费抢占式高可用

标签:keep   alived费   抢占式高可用   

原文地址:http://thankinglove.blog.51cto.com/2311485/1897515

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!