实验环境:
192.168.200.111 LVS DR模式调度器
192.168.200.112 httpd服务器
192.168.200.113 NFS共享服务器
192.168.200.114 httpd服务器
111机器的配置
yum -y install ipvsadm
ifconfig ens32:0 192.168.200.254 netmask 255.255.255.0
ipvsadm -A -t 192.168.200.254:80 -s rr
ipvsadm -a -t 192.168.200.254:80 -r 192.168.200.112:80 -g -w 1
ipvsadm -a -t 192.168.200.254:80 -r 192.168.200.114:80 -g -w 1
ipvsadm -Ln
112和114机器的配置
yum -y install httpd
echo "1111111" > /var/www/html/index.html (114 可以是33333)
systemctl start httpd
ifconfig lo:0 192.168.200.254 netmask 255.255.255.255
vim /etc/sysctl.conf
sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
测试
测试成功
二共享存储
113机器配置
yum -y install rpcbind nfs-utils
vim /etc/exports
/opt/wwwroot 192.168.200.0/24(rw,no_root_squash,sync)
mkdir /opt/wwwroot
systemctl start rpcbind (建议先打开rpcbind)
systemctl start nfs
[root@localhost ~]# showmount -e
Export list for localhost.localdomain:
/opt/wwwroot 192.168.200.0/24
echo "choudidi" >> /opt/wwwroot/index.html
112和114机器配置
showmount -e 192.168.200.113
mount 192.168.200.113:/opt/wwwroot /var/www/html/
cat /var/www/html/index.html
测试在网页上输入 192.168.200.112