首页 > 其他 > 详细

keepalived

时间:2016-11-16 03:30:02      阅读:279      评论:0      收藏:0      [点我收藏+]

主备之间不一样的地方仅有两处:优先级和状态

主:[root@node7_1 keepalived]# cat keepalived.conf

! Configuration File for keepalived


global_defs {

   notification_email {

     root@localhost

   }

   notification_email_from keepalived@localhost

   smtp_server 172.0.0.1

   smtp_connect_timeout 30

   router_id node1

   vrrp_mcast_group4 224.0.100.19

}


vrrp_instance VI_1 {

    state BACKUP 

    interface eno16777728

    virtual_router_id 1 

    priority 10

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass cb77b8da

    }

    virtual_ipaddress {

        192.168.1.251/32 dev eno16777728  #此处写DR模型中的VIP地址

    }

    notify_master "/etc/keepalived/notify.sh master"

    notify_backup "/etc/keepalived/notify.sh backup"

    notify_fault "/etc/keepalived/notify.sh fault"

}


virtual_server 192.168.1.251 80 { #此处写DR模型中的VIP地址

    delay_loop 3

    lb_algo rr

    lb_kind DR

    protocol TCP


    real_server 192.168.1.161 80 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 1

            nb_get_retry 3

            delay_before_retry 1

        }

    }


    real_server 192.168.1.162 80 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 1

            nb_get_retry 3

            delay_before_retry 1

        }

    }

}


备:

! Configuration File for keepalived


global_defs {

   notification_email {

     root@localhost

   }

   notification_email_from keepalived@localhost

   smtp_server 172.0.0.1

   smtp_connect_timeout 30

   router_id node1

   vrrp_mcast_group4 224.0.100.19

}


vrrp_instance VI_1 {

    state MASTER

    interface eno16777728

    virtual_router_id 1

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass cb77b8da

    }

    virtual_ipaddress {

        192.168.1.251/32 dev eno16777728  #此处写DR模型中的VIP地址

    }

    notify_master "/etc/keepalived/notify.sh master"

    notify_backup "/etc/keepalived/notify.sh backup"

    notify_fault "/etc/keepalived/notify.sh fault"

}


virtual_server 192.168.1.251 80 { #此处写DR模型中的VIP地址

    delay_loop 3

    lb_algo rr

    lb_kind DR

    protocol TCP


    real_server 192.168.1.161 80 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 1

            nb_get_retry 3

            delay_before_retry 1

        }

    }


    real_server 192.168.1.162 80 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 1

            nb_get_retry 3

            delay_before_retry 1

        }

    }

}


本文出自 “Linux” 博客,请务必保留此出处http://ridingonhorse.blog.51cto.com/11265295/1873172

keepalived

原文:http://ridingonhorse.blog.51cto.com/11265295/1873172

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!