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)