lvs-net實驗

來源:互聯網
上載者:User

標籤:lvs-net

Lvs-net實驗

環境:

server:centos6.7;外網IP:172.16.34.1;內網IP:192.168.74.129

RS1:centos7.2;內網IP:192.168.74.2;安裝nginx服務,監聽在80連接埠

RS2:centos7.2;內網IP:192.168.74.3;安裝httpd服務,監聽在8080連接埠

客戶機:centos6.7,IP:172.16.34.3

 

對配置好IP地址的RS進行驗證

[[email protected] html]# curlhttp://192.168.74.2RS1:192.168.74.2
[[email protected] html]# curlhttp://192.168.74.3:8080RS2:192.168.74.3

 

定義叢集服務:

[[email protected] html]#  ipvsadm -A -t 172.16.34.1:80 -s rr

 

查看定義的叢集服務

[[email protected] html]# ipvsadm -L -nIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port          Forward Weight ActiveConn InActConnTCP 172.16.34.1:80 rr

 

添加RS

[[email protected] html]# ipvsadm -a -t172.16.34.1:80 -r 192.168.74.2:80 -m(-w可添加權重,次數使用rr演算法,權重無意義)[[email protected] html]# ipvsadm -a -t172.16.34.1:80 -r 192.168.74.3:8080 -m

 

再次查看

[[email protected] html]# ipvsadm -L -nIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port          Forward Weight ActiveConn InActConnTCP 172.16.34.1:80 rr -> 192.168.74.2:80             Masq    1     0          0         -> 192.168.74.3:8080           Masq    1      0         0

 

開啟server的核心轉寄功能

[[email protected] html]# echo 1 >/proc/sys/net/ipv4/ip_forward

 

在客戶機上進行驗證

[[email protected] ~]# curl http://172.16.34.1RS2:192.168.74.3[[email protected] ~]# curl http://172.16.34.1RS1:192.168.74.2[[email protected] ~]# curl http://172.16.34.1RS2:192.168.74.3[[email protected] ~]# curl http://172.16.34.1RS1:192.168.74.2

 

修改演算法為wrr

添加權重

[[email protected]]# ipvsadm -e -t 172.16.34.1:80 -r 192.168.74.3:8080 -m -w2[[email protected]]# ipvsadm -e -t 172.16.34.1:80 -r 192.168.74.2:80 -m -w1

修改該演算法

[[email protected]]# ipvsadm -E -t 172.16.34.1:80 -s wrr

 

驗證

[[email protected] html]# ipvsadm -l -nIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port          Forward Weight ActiveConn InActConnTCP 172.16.34.1:80 wrr -> 192.168.74.2:80             Masq    1      0         0         -> 192.168.74.3:8080           Masq    2      0         0

 

[[email protected] ~]# for i in {1..10};do curlhttp://172.16.34.1;doneRS1:192.168.74.2RS2:192.168.74.3RS2:192.168.74.3RS1:192.168.74.2RS2:192.168.74.3RS2:192.168.74.3RS1:192.168.74.2RS2:192.168.74.3RS2:192.168.74.3RS1:192.168.74.2

 

顯示統計資料

[[email protected] html]# ipvsadm -Ln --statsIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port               Conns   InPkts OutPkts  InBytes OutBytes -> RemoteAddress:PortTCP 172.16.34.1:80                    32      187      116   15106    13674 -> 192.168.74.2:80                   13       77      48     6228     5616 -> 192.168.74.3:8080                 19      110       68    8878     8058

 

顯示速率

[[email protected] html]# ipvsadm -Ln --rateIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port                 CPS    InPPS  OutPPS    InBPS   OutBPS -> RemoteAddress:PortTCP 172.16.34.1:80                     0        0        0       0        0 -> 192.168.74.2:80                    0        0        0       0        0 -> 192.168.74.3:8080                  0        0        0       0        0


lvs-net實驗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.