目录
注:如果需要跨网段通信,调度器和节点服务器的默认网关要指向路由器的网关接口地址
实验准备
DR服务器:192.168.88.22
web服务器1:192.168.88.13
web服务器2:192.168.88.31
vip:192.168.88.250
nfs服务器:192.168.88.40
systemctl stop firewalld
setenforce 0
yum -y install ipvsadm
modprobe ip_vs
cat /proc/net/ip_vs
##配置虚拟IP地址##
cd /etc/sysconfig/network-scripts/
cp ifcfg-ens33 ifcfg-ens33:0
vim ifcfg-ens33:0
DEVICE=ens33:0
ONBOOT=yes
IPADDR=192.168.88.250
NETMASK=255.255.255.255
ifup ens33:0
ifconfig ens33:0
##调整proc响应参数##
vim /etc/sysctl.conf
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0
sysctl -p
##配置负载分配策略##
ipvsadm-save > /etc/sysconfig/ipvsadm
systemctl start ipvsadm
ipvsadm -C
ipvsadm -A -t 192.168.88.250:80 -s rr
ipvsadm -a -t 192.168.88.250:80 -r 192.168.88.13:80 -g
ipvsadm -a -t 192.168.88.250:80 -r 192.168.88.31:80 -g
ipvsadm
ipvsadm -ln
yum -y install nfs-utils rpcbind
mkdir /opt/yy /opt/cc
chmod 777 /opt/yy /opt/cc
vim /opt/yy/index.html
<html>
<body>
<h1>this is yy</h1>
<img src="123.jpg"/>
</body>
</html>
vim /opt/cc/index.html
<html>
<body>
<h1>this is cc</h1>
<img src="456.jpg"/>
</body>
</html>
vim /etc/exports
/opt/yy 192.168.88.0/24(rw,sync)
/opt/cc 192.168.88.0/24(rw,sync)
systemctl start rpcbind.service
systemctl start nfs.service
cd /etc/sysconfig/network-scripts/
cp ifcfg-lo ifcfg-lo:0
vim ifcfg-lo:0
DEVICE=lo:0
ONBOOT=yes
IPADDR=192.168.88.250
NETMASK=255.255.255.255
ifup lo:0
ifconfig lo:0
route add -host 192.168.88.250 dev lo:0
或
vim /etc/rc.local
/sbin/route add -host 192.168.88.250 dev lo:0
chmod +x /etc/rc.d/rc.local
##调整内核##
vim /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 1 #系统只响应目的IP为本地IP的ARP请求
net.ipv4.conf.lo.arp_announce = 2 #系统不使用IP包的源地址来设置ARP请求的源地址
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
sysctl -p
yum -y install nfs-utils rpcbind httpd
systemctl start rpcbind
systemctl start httpd
showmount -e 192.168.88.40
mount 192.168.88.40:/opt/yy /var/www/html
cd /etc/sysconfig/network-scripts/
cp ifcfg-lo ifcfg-lo:0
vim ifcfg-lo:0
DEVICE=lo:0
ONBOOT=yes
IPADDR=192.168.88.250
NETMASK=255.255.255.255
ifup lo:0
ifconfig lo:0
route add -host 192.168.88.250 dev lo:0
或
vim /etc/rc.local
/sbin/route add -host 192.168.88.250 dev lo:0
chmod +x /etc/rc.d/rc.local
##调整内核##
vim /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 1 #系统只响应目的IP为本地IP的ARP请求
net.ipv4.conf.lo.arp_announce = 2 #系统不使用IP包的源地址来设置ARP请求的源地址
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
sysctl -p
yum -y install nfs-utils rpcbind httpd
systemctl start rpcbind
systemctl start httpd
showmount -e 192.168.88.40
mount 192.168.88.40:/opt/cc /var/www/html