First, the working principle of Server Load balancer in network address translation mode: the client accesses the director machine, and the director machine sends client requests to the real server, and then the real server responds to the director machine, the director machine then returns the response to the client. This low efficiency is generally only applicable to small enterprises. Experiment environment: two host servers: 192.168.0.11 and 192.168.0.12 (the server is in the same Intranet network segment
First, the working principle of Server Load balancer in network address translation mode: the client accesses the director machine, and the director machine sends client requests to the real server, and then the real server responds to the director machine, the director machine then returns the response to the client. This low efficiency is generally only applicable to small enterprises.
Experiment environment: two host servers: 192.168.0.11 and 192.168.0.12 (the server is in the same Intranet segment)
Medium transfer (two NICS): 192.168.0.13 and 192.168.513
Client: 192.168.5.10
(The host name must be consistent with the IP address. Iptables: clear -- iptables-F. Selinux disabled)
Tutorial steps:
A. Server:
1. 192.168.0.11
# Yum install-y httpd
# Service httpd start
# Echo "192.168.0.11">/var/www/html/index.html
# Route add default gw 192.168.0.13
2. 192.168.0.12
# Yum install-y httpd
# Service httpd start
# Echo "192.168.0.12">/var/www/html/index.html
# Route add default gw 192.168.0.13
B. Intermediate transfer:
1. Install the ipvs service:
# Yum clean all
# Yum install-y ipvsadm
2. Enable the ip forwarding function and disable other services.
# Echo "1">/proc/sys/net/ipv4/ip_forward
# Echo "0">/proc/sys/net/ipv4/conf/all/send_redirects
# Echo "0">/proc/sys/net/ipv4/conf/default/send_redirects
# Echo "0">/proc/sys/net/ipv4/conf/eth0/send_redirects
# Echo "0">/proc/sys/net/ipv4/conf/eth1/send_redirects
3. Set transfer:
Vim setNet
/Sbin/ipvsadm-C
/Sbin/ipvsadm-A-t 192.168.5.13: 80-s rr
/Sbin/ipvsadm-a-t 192.168.5.13: 80-r 192.168.0.11: 80-m-w 1
/Sbin/ipvsadm-a-t 192.168.5.13: 80-r 192.168.0.12: 80-m-w 1
/Sbin/ipvsadm
#./SetNet
C. Client:
1. Add IP addresses of 5 CIDR blocks
# Ifconfig eth0: 5 192.168.5.10
# Ping 192.168.5.13
2. Open http: // 192.168.5.13/in the browser. Refresh the page again. If the page is different, the experiment is successful !)