1. Experimental environment:
1.1 Three servers, one for the LVS server, the other two for Apache
1.2 LVS server has two network cards, VIP is 10.10.10.11 (address of service), Dip is 192.168.10.1 (address with RIP communication).
1.3 The other two servers are a network card, the address and the LVS Server intranet network card in the same network segment; the APACHE1 URL is 192.168.10.2,apache2 address 192.168.10.3.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7B/67/wKioL1bNRX3wTwqTAACN1h58PSg076.png "title=" topology. png "alt=" Wkiol1bnrx3wtwqtaacn1h58psg076.png "/>
2. Basic configuration:
2.1 Since LVS cannot be used with iptables, ensure that iptables on the LVS server is closed;
2.2 For the sake of experiment convenience, the iptables of each real server is also closed;
2.3 Turn off all selinux.
On all servers, execute the following command:
[[email protected] ~]#/etc/init.d/iptables stop[[email protected] ~]# Setenforce 0
3. Configure each server IP address and:
3.1 Configure the LVS server with a ip:eth0 of vip,eth1 as dip.
[[email protected] ~]# ifconfig eth0 10.10.10.11/24 up[[email protected] ~]# ifconfig eth1 192.168.10.1/24 up
3.2 Configure the IP address and gateway address of the real server:
3.2.1 Apache1:
[[email protected] ~]# ifconfig eth0 192.168.10.2/24 up[[email protected] ~]# route add default GW 192.168.10.1
3.2.2 Apache2:
[[email protected] ~]# ifconfig eth0 192.168.10.3/24 up[[email protected] ~]# route add default GW 192.168.10.1
4. Configure LVS to provide load balancing services:
4.1 Installing the IPVSADM service:
[email protected] ~]# Yum install-y ipvsadm
4.2 Adding the LVS Cluster service:
[[email protected] ~]# ipvsadm-a-t 10.10.10.11:80-s RR
4.3 Add a real Server to the LVS Cluster service:
[[email protected] ~]# ipvsadm-a-t 10.10.10.11:80-r 192.168.10.2-m[[email protected] ~]# ipvsadm-a-t 10.10.10.11:80 -R 192.168.10.3-m
4.4 Turn on server forwarding mode (temp):
[Email protected] ~]# echo 1 >/proc/sys/net/ipv4/ip_forward
4.5 Turn on the server forwarding mode (permanent):
[Email protected] ~]# sed-i ' [email protected]\ (net.ipv4.ip_forward = \) [email protected]\[email protected] '/ETC/SYSCT L.conf
5. For real server to provide HTTPD services, Apache1 provide Web page file content for Web1,apache2 to provide Web page file content for WEB2: (two server operations basically consistent, I only show one of them):
5.1 Installing the HTTPD service:
[email protected] ~]# Yum install-y httpd
5.2 Providing Web page files:
[[email protected] ~]# echo
5.3 Start the server:
[[Email protected] ~]# service httpd start
This has been configured to end, you can test yourself. I don't have stickers!
This article is from the "Bigmanager" blog, make sure to keep this source http://minux.blog.51cto.com/8994862/1744626
NAT configuration of LVS load balancing