项目笔记:6.利用LVS实现网站流量高效快速的分发

时间:2021-04-08 03:09:26

项目笔记:6.利用LVS实现网站流量高效快速的分发

项目笔记:6.利用LVS实现网站流量高效快速的分发

1、在LVS调度器192.168.0.9

# yum -y install ipvsadm
# ipvsadm -A -t 192.168.0.253:80 -s rr
# ipvsadm -a -t 192.168.0.253:80 -r 192.168.0.1 -g
# ipvsadm -a -t 192.168.0.253:80 -r 192.168.0.8 -g

# ifconfig eth0:100 192.168.0.253/32 up


2、在后端节点192.168.0.1和192.168.0.8做如下操作

# vim /opt/lvs-dr.sh
#!/bin/sh
VIP=192.168.0.253
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev lo:0
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce

# /bin/bash /opt/lvs-dr.sh

创建回环接口用于相应lvs(0.9)