LVS-DR模型測試實驗

來源:互聯網
上載者:User

標籤:webseven   lvs   dr   ipvsadm   

DR模型解決的realserver中的VIP與Dispatcher中的VIP在同一個網路的不同辦法:

1.通過路由器上設定mac地址綁定,將VIP對應的mac地址寫入路由器.

2.通過realserver的arptables定義規則.

3.通過作業系統的核心參數來解決.

arp_ignore:

定義接收到arp請求時的響應層級,預設為0.

0.只要本地有響應的地址,就進行響應.

1.僅在請求的目標地址配置在請求的介面上時,進行響應.

arp_announce:

定義將自己的地址向外通告時的通告層級,預設為0.

0:將本機任何介面上的任何地址向外通告.

1:盡量向目標網路通告與其網路匹配的地址.

2.總是向目標網路通告與其網路匹配的地址.


本實驗實驗第3中方法


1.規劃IP地址:

Dispatcher伺服器,一塊網卡:

eth0的IP地址:10.0.7.100/16

eth0:0的IP地址:10.0.7.101/16

Realserver1伺服器一塊網卡:

IP地址:10.0.7.108/16

Realserver2伺服器一塊網卡:

IP地址:10.0.7.109/16


2.設定realserver1主機的核心參數與網路資訊:

sysctl -p net.ipv4.conf.all.arp_ingore=1

sysctl -p net.ipv4.conf.eth0.arp_ingore=1

sysctl -p net.ipv4.conf.all.arp_announce=2

sysctl -p net.ipv4.conf.eth0.arp_announce=2

若要上述資訊永久生效需要寫入/etc/sysctl.conf的設定檔.

ifconfig lo:0 10.0.7.100 broadcast 10.0.7.100 netmask 255.255.255.255 up

若要上述資訊永久生效需要寫入/etc/sysconfig/network-scripts/ifcfg-lo0的設定檔.

route add -host 10.0.7.100 dev lo:0

3.設定realserver2主機的核心參數與網路資訊:

sysctl -p net.ipv4.conf.all.arp_ingore=1

sysctl -p net.ipv4.conf.eth0.arp_ingore=1

sysctl -p net.ipv4.conf.all.arp_announce=2

sysctl -p net.ipv4.conf.eth0.arp_announce=2

若要上述資訊永久生效需要寫入/etc/sysctl.conf的設定檔.

ifconfig lo:0 10.0.7.100 broadcast 10.0.7.100 netmask 255.255.255.255 up

若要上述資訊永久生效需要寫入/etc/sysconfig/network-scripts/ifcfg-lo0的設定檔.

route add -host 10.0.7.100 dev lo:0

4.設定Dispatcher的網卡:

ifconfig eth0:1 10.0.7.100 broadcast 10.0.7.100 netmask 255.255.255.255 up

echo 1 > /proc/sys/net/ipv4/ip_forward

route add -host 10.0.7.100 dev eth0:0


5.配置lvs:

[[email protected] ~]# ipvsadm -A -t  10.0.7.100:80 -s wlc 

[[email protected] ~]# ipvsadm -a -t  10.0.7.100:80 -r 10.0.7.108 -g  -w 3 

[[email protected] ~]# ipvsadm -a -t  10.0.7.100:80 -r 10.0.7.109 -g  -w 6

[[email protected] ~]# ipvsadm -Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

 -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

TCP  10.0.7.100:80 wlc

 -> 10.0.7.109:80                Route   6      0          0         

 -> 10.0.7.108:80                Route   3      0          0         

[[email protected] ~]# service ipvsadm save

ipvsadm: Saving IPVS table to /etc/sysconfig/ipvsadm: [確定]


6.測試:

ab -n 10000 -c 200 http://10.0.7.100


7.查看狀態:

[[email protected] ~]# ipvsadm -L --stats

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port               Conns   InPkts  OutPkts  InBytes OutBytes

 -> RemoteAddress:Port

TCP  10.0.7.100:http                     4        4        0      208        0

 -> 10.0.7.108:http                     3        3        0      156        0

 -> 10.0.7.109:http                     1        1        0       52        0

[[email protected] ~]# 

8.至此,LVS的DR模型測試完成.


本文出自 “webseven” 部落格,請務必保留此出處http://webseven.blog.51cto.com/4388012/1548027

LVS-DR模型測試實驗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.