dr 模型
1、 directory ,node1 ,node2 三台主机都是一块网块, 并且网卡都为桥接,且node1,nod2,不需要指定网关
- 在director主机中执行
#ip addr add 192.168.1.20/32 dev ens33
# ipvsadm -A -t 192.168.1.20:80 -s rr
# ipvsadm -a -t 192.168.1.20:80 -r 192.168.1.21:80 -g
#ipvsadm -a -t 192.168.1.20:80 -r 192.168.1.21:80 -g
- 在node1中
#vim setkp.sh
#!/bin/bash
vip=192.168.1.20
mask=255.255.255.255
case $1 in
start)
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
ifconfig lo:0 $vip netmask $mask broadcast $vip up
route add -host $vip dev $interface
;;
stop)
ifconfig lo:0 down
echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce
;;
esac
#chmod +x setkp.sh
#./setkp.sh start
# systemctl start httpd
echo “<h1>NODE1</h1>” > /var/www/html/index.html
#cat /proc/sys/net/ipv4/conf/all/arp_ignore
#cat /proc/sys/net/ipv4/conf/all/arp_announce
#ls
#scp setkp.sh 192.168.1.22:/root
- 在node2中执行
#chmod +x setkp.sh
#./setkp.sh start
# systemctl start httpd
echo “<h2>NODE2</h2>” > /var/www/html/index.html
在其它主机中进行测试
#for i in {1..4} ; do curl 172.16.252.166; done
<h1>RS1</h2>
<h1>RS2</h2>
<h1>RS2</h2>
<h1>RS2</h2>
原创文章,作者:nene,如若转载,请注明出处:http://www.178linux.com/88064