服务器系统 | CentOS release 6.5 |
---|---|
内存 | 1G |
CPU | 2核 |
IP地址 | 192.168.46.129 |
服务 | Lvs负载调度器 |
服务器系统 | CentOS release 6.5 |
---|---|
内存 | 1G |
CPU | 2核 |
IP地址 | 192.168.46.130 |
服务 | Web服务器 |
服务器系统 | CentOS release 6.5 |
---|---|
内存 | 1G |
CPU | 2核 |
IP地址 | 192.168.46.138 |
服务 | Web服务器 |
在第一台LVS调度器上操作
cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-eth0:0
vi ifcfg-eth0:0
ifup eth0:0
ifconfig
yum -y install ipvsadm
两台Web服务器上操作
yum -y install httpd
再回到第一台LVS调度器上操作
ipvsadm -A -t 192.168.46.100:80 -s rr
ipvsadm -a -t 192.168.46.100:80 -r 192.168.46.130:80 -g -w 1
ipvsadm -a -t 192.168.46.100:80 -r 192.168.46.138:80 -g -w 1
service ipvsadm save
在第二台Web服务器上操作
cd /etc/sysconfig/network-scripts/
cp ifcfg-lo ifcfg-lo:0
vi ifcfg-lo:0
ifup lo:0
vi /etc/rc.local
/sbin/route add -host 192.168.46.100 dev lo:0
route add -host 192.168.46.100 dev lo:0
vi /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
sysctl -p
vi /var/www/html/index.html
web-130130130130130130
service iptables stop
setenforce 0
service httpd start
在第三台Web服务器上操作
cd /etc/sysconfig/network-scripts/
cp ifcfg-lo ifcfg-lo:0
vi ifcfg-lo:0
ifup lo:0
vi /etc/rc.local
/sbin/route add -host 192.168.46.100 dev lo:0
route add -host 192.168.46.100 dev lo:0
vi /etc/sysctl.conf
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
sysctl -p
vi /var/www/html/index.html
web-138138138138138138
service iptables stop
setenforce 0
service httpd start
再回到第一台LVS调度器上操作
service iptables stop
setenforce 0
ipvsadm -ln