三臺服務器
Real server 1: 10.10.10.51
Real server 2: 10.10.10.52
LVS Directory: 10.10.10.53
VIP: 10.10.10.111
所有服務器關閉selinux 和 iptableshtml
Real server 1linux
yum install httpd -y echo "Real Server 1" > /var/www/html/index.html service httpd start echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce ifconfig lo:1 10.10.10.111/32 up
Real server 2瀏覽器
yum install httpd -y echo "Real Server 2" > /var/www/html/index.html service httpd start echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce ifconfig lo:1 10.10.10.111/32 up
Directorbash
yum install ipvsadm -y ifconfig eth0:1 10.10.10.111/32 up ipvsadm -A -t 10.10.10.111:80 -s rr ipvsadm -a -t 10.10.10.111:80 -r 10.10.10.51 -g ipvsadm -a -t 10.10.10.111:80 -r 10.10.10.52 -g
瀏覽器打開http://10.10.10.111,按CRTL+F5刷新,查看效果服務器