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

keepalived主从配置

时间:2018-07-04 11:46:19      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:ble   ali   val   pac   virt   vim   tab   router   .sh   

主: 192.168.39.83

vim keepalived.conf

! Configuration File for keepalived


global_defs {

   router_id nginx_master

}


vrrp_script chk_nginx {

    script "/data/scripts/nginx_check.sh"

    interval 2

}


vrrp_instance VI_1 {

    state MASTER

    interface em1

    virtual_router_id 51

    priority 101

    advert_int 1


    track_script {

        chk_nginx

    }


    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {        

        192.168.39.20/24

        192.168.39.21/24

    }

}


vrrp_instance VI_2 {

    state BACKUP

    interface em1

    virtual_router_id 52

    priority 99

    advert_int 1


    track_script {

        chk_nginx

    }


    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.39.10/24

        192.168.39.11/24

    }

}



从:192.168.39.84

vim keepalived.conf

! Configuration File for keepalived


global_defs {

   router_id nginx_backup

}


vrrp_script chk_nginx {

    script "/data/scripts/nginx_check.sh"

    interval 2

}


vrrp_instance VI_1 {

    state BACKUP

    interface em1

    virtual_router_id 51

    priority 99

    advert_int 1


    track_script {

        chk_nginx

    }


    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

       192.168.39.20/24

       192.168.39.21/24

    }

}


vrrp_instance VI_2 {

    state MASTER

    interface em1

    virtual_router_id 52

    priority 101

    advert_int 1


    track_script {

        chk_nginx

    }


    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

       192.168.39.10/24

       192.168.39.11/24

    }


}


注: iptables需要开启vrrp协议访问

iptables -I INPUT -p vrrp -j ACCEPT

keepalived主从配置

标签:ble   ali   val   pac   virt   vim   tab   router   .sh   

原文地址:http://blog.51cto.com/haoyonghui/2135854

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