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

vrrp下的lvs-dr实验

时间:2017-05-15 22:41:35      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:keepalived lvs

网络拓扑结构

技术分享

操作系统为centos7.3

1.所有主机RS1RS2DS1DS2都开apache服务器,RS1 RS2都用来测试web服务器的,DS1 DS2是用来做sorry 服务器的。

2.所有服务器都时间同步

3.DS上开vrrp

技术分享

DS1上配置

! Configuration File for keepalived

 

global_defs {

   notification_email {

     root@localhost

   }

   notification_email_fromAlexandre.Cassen@firewall.loc

   smtp_server 127.0.0.1

   smtp_connect_timeout 30

   router_id node1

}

 

vrrp_instance jin-vrrp {

    state MASTER

    interface ens37

    virtual_router_id 51

    priority 100

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.0.200/24 devens37

    }

}

 

virtual_server 192.168.0.200 80 {

    delay_loop 6

    lb_algo wrr

    lb_kind DR

    persistence timeout 50

    protocol TCP

    sorry_server 127.0.0.1 80

    real_server 192.168.0.10380 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 3

            nb_get_retry 3

            delay_before_retry3

        }

 }

    real_server 192.168.0.10480 {

                                                        weight1

                                                        HTTP_GET{

                                                        url{

                                                                 path/

                                                                 status_code200

                                                                  }

                                                            }

                                                        connect_timeout3

                                                        nb_get_retry3

                                                        delay_before_retry3

                               } 

    }

}

DS2上配置

! Configuration File for keepalived

 

global_defs {

   notification_email {

     root@localhost

   }

   notification_email_fromAlexandre.Cassen@firewall.loc

   smtp_server 127.0.0.1

   smtp_connect_timeout 30

   router_id node1

}

 

vrrp_instance jin-vrrp {

    state BACKUP

    interface ens37

    virtual_router_id 51

    priority 98

    advert_int 1

    authentication {

        auth_type PASS

        auth_pass 1111

    }

    virtual_ipaddress {

        192.168.0.200/24 dev ens37

    }

}

 

virtual_server 192.168.0.200 80 {

    delay_loop 6

    lb_algo wrr

    lb_kind DR

    persistence timeout 50

    protocol TCP

    sorry_server 127.0.0.1 80

    real_server 192.168.0.10380 {

        weight 1

        HTTP_GET {

            url {

              path /

              status_code 200

            }

            connect_timeout 3

            nb_get_retry 3

            delay_before_retry3

        }

 }

    real_server 192.168.0.10480 {

                                                        weight1

                                                        HTTP_GET{

                                                        url{

                                                                 path/

                                                                 status_code200

                                                                  }

                                                            }

                                                        connect_timeout3

                                                        nb_get_retry3

                                                        delay_before_retry3

                               } 

    }

}

做这个实验的时候要小心花括号。

4.在二个RS服务上写脚本用来做lvs-dr里的VIP

技术分享

技术分享


lo上生成vip地址及路由条目。

技术分享

5.由于二个DS配完keepalivedvrrp后。只要yum ipvsadm就可以了,至于ipvsadm策略会通过keepalived会自动生成

技术分享

6.测试结果

技术分享

vrrp下的lvs-dr实验

标签:keepalived lvs

原文地址:http://jinshaolong.blog.51cto.com/753804/1925907

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