1,准备三台虚拟机
2,先配置三台虚拟机的网络
- eth0,配置在一个网段
DIP,RIP在一个网段
3,配置lvs的VIP
-ifconfig eht0:192.168.9.100/24
-echo "1" > /proc/sys/net/ipv4/ip_forward
4,调整RS的相应,通告级别(每一台RS都配):
-echo 1 > /proc/sys/net/ipv4/conf/eth0//arp_ignore
-echo 2 > /proc/sys/net/ipv4/conf/eth0//arp_announce
-echo 2 > /proc/sys/net/ipv4/conf/eth0//arp_ignore
-echo 1 > /proc/sys/net/ipv4/conf/eth0//arp_announce
5,配置RS的VIP(每一台RS都配)
-ifconfig lo:8 192.168.9.100 netmask 255.255.255.255
eth0
node01 LVS ipvsadm DIP eth0 VIP 配置ipvsadm
node02 RS01 httpd 80 RIP lo:0 VIP 先调整内核ARP通告和相应级别 启动httpd
node03 RS02 httpd:80 RIP lo:0 VIP 先调整内核ARP通告和相应级别 启动httpd
6,启动RS上的httpd
- yum install httpd -y
- /var/www/html
vi index.html
from ooxxip
- service httpd start
客户端验证:RIP:80能显示
-VIP:80不能显示
7,LVS——ipvsadm
-yum install ipvsadm -y
-ipvsadm -A -t 192.168.9.100:80 -s rr
-ipvsadm -a -t 192.168.9.100:80 -r 192.168.9.12 -g
-ipvsadm -a -t 192.168.9.100:80 -r 192.168.9.13 -g
-ipvsadm -ln
-浏览器刷新:访问vip
-ipvsadm -lnc
-netstart -natp