标签:linu tor lse route add oca 设置 direct out UNC
实践所需材料Director节点:ens33 : 192.168.199.181 vip :192.168.199.167
Real server1:ens33 : 192.168.199.199 vip :192.168.199.167
Real server2:ens33 : 192.168.199.154 vip : 192.168.199.167
开启nginx:./nginx(关闭./nginx -s stop)
关闭防火墙 和 SElinux
systemctl stop firewalld.service
setenforce 0
director机yum安装ipvsadm
director配置脚本
#vim /usr/local/sbin/lvs_dr.sh
#! /bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
ipv=/sbin/ipvsadm
vip=192.168.199.167
rs1=192.168.199.199
rs2=192.168.199.154
ifconfig ens33:0 down
ifconfig ens33:0 $vip broadcast $vip netmask 255.255.255.255 up
route add -host $vip dev ens33:0
$ipv -C
$ipv -A -t $vip:80 -s wrr
$ipv -a -t $vip:80 -r $rs1:80 -g -w 3
$ipv -a -t $vip:80 -r $rs2:80 -g -w 1
然后bash执行脚本
bash /usr/local/sbin/lvs_dr.sh
两台rs机配置脚本
#vim /usr/local/sbin/lvs_dr_rs.sh
#! /bin/bash
vip=192.168.199.167
ifconfig lo:0 $vip broadcast $vip netmask 255.255.255.255 up
route add -host $vip 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
然后bash执行脚本
bash /usr/local/sbin/lvs_dr_rs.sh
查看ipvsadm设置的规则
ipvsadm -ln
关闭防火墙 SElinux
systemctl stop firewalld.service
setenforce 0
在网页输入vip:192.168.199.167查看效果
关闭另一台rs的NGINX之后。显示另一虚拟机的访问NGINX页面
标签:linu tor lse route add oca 设置 direct out UNC
原文地址:https://blog.51cto.com/14375810/2424033