Linux-lvs load balancing based on Apache Service (NAT mode)

Source: Internet
Author: User

Lab Environment:
Three CentOS7 because it is analog, the outside network should not and intranet a network segment.
lvs:192.168.127.137 (External Network) 192.168.245.130 (intranet)
vip:192.168.245.222
rs1:192.168.245.128 (Intranet)
rs2:192.168.245.129 (Intranet)
1, first shut down the firewall and SELinux, empty iptables rules (experimental environment only)
Each one needs to be done:

2. Install LVS software on the LVS host:

1) Turn on the route forwarding function:

2) Empty the Ipvsadm table

3) Add a new virtual service (virtual intranet IP)

-A add a new virtual server record
-T means using the TCP protocol
4) Add back-end real server records

-A indicates that a new record is added to the virtual server and can also be understood as binding
-M means NAT mode is used
-W indicates weights
-R indicates backend real server
3. Build Apache service on the back-end RS Real server
1) Install Apache Service


2) Create a test page


3) Set HTTP listening port for 0.0.0.0:80, 0.0.0.0 for all networks (or set the network management of the two intranet servers to the intranet on the LVS, the address of the network card)



Restart the HTTPD service:


4. Test LVS:

Because the weights set are the same, they are polled for access.
Thinking about a question, what if the two sites require the same content to be implemented?
There are many scenarios where you can use NFS mount, rsync sync, etc.
You can also set the server after the first visit to access this URL, the same server is responsible for responding, so that you have to log on to a site a bit of refresh, causing the problem is not logged in.
Use the external network address to distribute the request to the back-end RS, the Web site's domain name resolution to the external network address can!

Linux-lvs load balancing based on Apache Service (NAT mode)

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.