Lvs-net Experiment

Source: Internet
Author: User

Lvs-net Experiment

Environment:

server:centos6.7; external network ip:172.16.34.1; intranet ip:192.168.74.129

rs1:centos7.2, intranet ip:192.168.74.2; Install Nginx service, monitor on port 80

rs2:centos7.2, intranet ip:192.168.74.3; Install httpd service, monitor on port 8080

Client: centos6.7,ip:172.16.34.3

Verify the RS with the IP address configured

[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

Define the Cluster service:

[[email protected] html]# ipvsadm-a-t 172.16.34.1:80-s RR

View the defined Cluster service

[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

Add RS

[[email protected] html]# ipvsadm-a-t172.16.34.1:80-r 192.168.74.2:80-m (W can add weights, number of times using RR algorithm, weight meaningless) [[email protected] html]# ipvsadm-a-t172.16.34.1:80-r 192.168.74.3:8080-m

Check Again

[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

Open the core forwarding feature of the server

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

Validating on the client

[[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

Modify the algorithm to WRR

Add weights

[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

Modify the algorithm

[Email protected]]# ipvsadm-e-T 172.16.34.1:80-s WRR

Verify

[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};d o 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

To display statistical data

[[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

Display Rate

[[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 Experiment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.