准备工作
关闭iptables
关闭SElinux
Director
开启端口转发
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
确认是否开启
cat /proc/sys/net/ipv4/ip_forward
安装IPVSADM
yum -y install ipvsadm
添加集群服务
ipvsadm -A -t 192.168.177.69:80 -s wrr
添加集群上RS
ipvsadm -a -t 192.168.177.69:80 -r 192.168.152.141:80 -m -w1 ipvsadm -a -t 192.168.177.69:80 -r 192.168.152.142:80 -m -w2
RS1
安装HTTPD服务
编辑主页
vim /var/www/html/index.html
<h1>RS1</h1>
RS2
安装HTTPD服务
vim /var/www/html/index.html
<h1>RS2</h1>
Director,RS1,RS2均用单网卡即可
Director
在eno16777736添加secondary ip地址作为VIP
ifconfig eno16777736:0 192.168.177.70 netmask 255.255.255.255 broadcast 192.168.177.70
RS1
限制内核参数禁止arp宣告和响应
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
为lo接口添加VIP
ifconfig lo:0 192.168.177.70 netmask 255.255.255.255 broadcast 192.168.177.70
添加到达192.168.177.70的路由转发
route add -host 192.168.177.70 dev lo:0
RS2设置与RS1相同
本文出自 “liberalism” 博客,请务必保留此出处http://edonkey.blog.51cto.com/887243/1772290
原文地址:http://edonkey.blog.51cto.com/887243/1772290