Lvs-nat implementing a Web server lb cluster

Source: Internet
Author: User

Objective:

This article turns to self personal blog http://www.anyisalin.com welcome everyone to visit




Lvs-nat FLow Chart

650) this.width=650; "src=" Http://www.anyisalin.com/wp-content/uploads/2016/01/20160115212128_41058.png "alt=" 20160115212128_41058.png "/>

Introduction to the experimental environment

There are three servers, as follows:

Lvs-director : External Network IP 192.168.1.107 Intranet IP 172.16.100.1

lvs-rs1 : IP 172.16.100.8 netmask 255.255.255.0 gateway172.16.100.1

lvs-rs2 : IP 172.16.100.9 netmask 255.255.255.0 gateway172.16.100.1

Note: Three servers are in the same network segment

Experiment Configuration

Configure separately lvs-rs1 , lvs-rs2 to be Web Server

lvs-rs1 :

Yum Install httpd service httpd startsetenforce 0echo "This is Lvs-rs1" >/var/www/html/index.html


lvs-rs2 :

Yum install httpdservice httpd startsetenforce 0echo "This is Lvs-rs2" >/var/www/html/index.html


Configuration Lvs-director Use Lvs-nat type, Round Robin the dispatch mode of the two servers to achieve load balancing

Lvs-director :

       grep -I  "Ip_vs"/boot/config  #查看当前内核是否编译了ipvs模块          Enable IP Forwarding,echo 1> /proc/sys/net/ipv4/ip_forward         #如果想永久生效需写入/etc/sysctl.conf file in        yum  install ipvsadm       #安装lvs命令行管理工具         service iptables stop      #关闭iptables because iptables and Ipvs cannot be turned on at the same time        service ipvsadm start     #启用ipvsadm进程        ipvsadm -a -t  192.168.1.107 -s rr            #添加一个虚拟服务地址, using RR (roundrobin) scheduling method         ipvsadm -a -t 192.168.1.107 -r172.16.100.8 -m         #添加一台realServer, run        ipvsadm -a -t 192.168.1.107 in a masquerade way  -r172.16.100.9 -m         #添加一台realserver, run in a masquerade way


Test:

Use other hosts to access

650) this.width=650; "src=" Http://www.anyisalin.com/wp-content/uploads/2016/01/20160115211722_87264.png "alt= "20160115211722_87264.png"/>

test with the ab command

650) this.width=650; "src=" Http://www.anyisalin.com/wp-content/uploads/2016/01/20160115211734_78525.png "alt=" 20160115211734_78525.png "/>

View current LVS status

650) this.width=650; "src=" Http://www.anyisalin.com/wp-content/uploads/2016/01/20160115211802_69635.png "alt=" 20160115211802_69635.png "/>

It can be learned thatRR Scheduling is balanced forwarding

The actual application, the different server possibility can have the difference, must consider the weight, therefore uses Weightround Robin the Scheduling method

Lvs-director

Ipvsadm-e-t 192.168.1.107:80-s WRR #修改虚拟服务器的调度方式为wrr ipvsadm-e-T 192.168.1.107:80-r172.16.100.8-m-W 3 #将R The weight of the S1 is set to 3 ipvsadm-e-T 192.168.1.107:80-r172.16.100.9-m-W 1 #将RS2的权重设置为1


Test

Use other hosts to access

650) this.width=650; "src=" Http://www.anyisalin.com/wp-content/uploads/2016/01/20160115211920_44916.png "alt=" 20160115211920_44916.png "/>

test with the ab command

650) this.width=650; "src=" Http://www.anyisalin.com/wp-content/uploads/2016/01/20160115211921_38131.png "alt=" 20160115211921_38131.png "/>

View current LVS status

650) this.width=650; "src=" Http://www.anyisalin.com/wp-content/uploads/2016/01/20160115211921_18642.png "alt=" 20160115211921_18642.png "/>

from This, it can be learned thatthe higher the weight of WRR in the dispatch mode, the priority forwarding


This article is from the "The Anyisalin blog" blog, please be sure to keep this source http://anyisalin.blog.51cto.com/10917514/1736293

Lvs-nat implementing a Web server lb cluster

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.