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

集群——lvs实验篇

时间:2014-08-25 19:31:55      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:lvs

NAT模式实验:

CIP:192.168.100.101/24(vmnet5)

VIP:192.168.100.100/24(vmnet5)

DIP:172.16.100.1/16/eth0  (vmnet1)

RIP1:172.16.100.15/16/eth0(vmnet1)

RIP2:172.16.100.16/16/eth0(vmnet1)


RS上的操作:

    准备httpd服务,并且准备不同的页面。

    设定RS的网关指向DIP

Director上的操作:

    # vim /etc/sysctl.conf

        net.ipv4_forword = 1

    # sysctl -p

    # ipvsadm -A -t 192.168.100.100:80 -s rr

    # ipvsadm -a -t 192.168.100.100:80 -r 172.16.100.15 -m

    # ipvsadm -a -t 192.168.100.100:80 -r 172.16.100.16 -m

    # ipvsadm -Ln --stats

客户端的操作:

    # elinks http://192.168.100.100/index.html


DR模型:

(1)当VIP和DIP、RIP在同一个网段内时:

    Director:

        DIP:172.16.100.1/16/eth0

        VIP:172.16.100.11/32/eth0:0

    RS1:

        RIP:172.16.100.15/16/eth0

        VIP:172.16.100.11/32/lo

    RS2:

        RIP:172.16.100.16/16/eth0

        VIP:172.16.100.11/32/lo

    CIP:172.16.100.101/16


RS1上的操作:

        # echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore

        # echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore

        # echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce 

        # echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce 

        # ifconfig lo:0 172.16.100.11 broadcast 172.16.100.11 netmask 255.255.255.255 up

        # route add -host 172.16.100.11 dev lo:0(使得数据报文无论从哪个网卡出去,IP地址都是VIP)

        RS2上的操作同上,而且准备不同的web页面。

Director上的操作:

    # ifconfig eth0:0 172.16.100.11 broadcast 172.16.100.11 netmask 255.255.255.255 up

    # ipvsadm -A -t 172.16.100.11:80 -s rr

    # ipvsadm -a -t 172.16.100.11:80 -r 172.16.100.15 -g

    # ipvsadm -a -t 172.16.100.11:80 -r 172.16.100.16 -g

客户端操作:

    # elinks http://172.16.100.11/index.html(此时Director上无法访问)

  

(2)当VIP和DIP、RIP不在同一个网段内时:

    Director:

        DIP:172.16.100.1/16/eth0

        VIP:192.168.100.11/32/eth0:0

    RS1:

        RIP:172.16.100.15/16/eth0

        VIP:192.168.100.11/32/lo

    RS2:

        RIP:172.16.100.16/16/eth0

        VIP:192.168.100.11/32/lo

    CIP:172.16.100.101/16


RS1上的操作:

        # echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore

        # echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore

        # echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce 

        # echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce

        # ifconfig lo:0 192.168.100.11 broadcast 192.168.100.11 netmask 255.255.255.255 up

        # route add default gw 172.16.100.17

        # route add -host 192.168.100.11 dev lo:0

添加RS的网关设备:

        # ifconfig eth0 172.16.100.17

        # ifconfig eth0:0 192.168.100.17

        # vim /etc/sysctl.conf

            net.ipv4_forword = 1

        # sysctl -p

        #如果可能的话还可以给这个路由设备添加一个网关



            


 



  

    


    


    








集群——lvs实验篇

标签:lvs

原文地址:http://caduke.blog.51cto.com/3365689/1544804

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