实验 详解部署LVS-DR群集

一 实验环境

调度器:192.168.100.11 ens33:0:192.168.100.100(VIP)
存储服务器:192.168.100.15
web1:192.168.100.12 ens33:0:192.168.100.100(VIP)
web2:192.168.100.13 ens33:0:192.168.100.100(VIP)

二 实验拓扑

在这里插入图片描述

三 实验步骤

调度器

##配置ens33:0##
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33:0
[root@localhost network-scripts]# vi ifcfg-ens33:0
NAME=ens33:0
DEVICE=ens33:0
ONBOOT=yes
IPADDR=192.168.100.100
NETMASK=255.255.255.255
[root@localhost network-scripts]# ifup ifcfg-ens33:0
[root@localhost network-scripts]# ifconfig

##调整/proc响应参数##
[root@localhost network-scripts]# vi /etc/sysctl.conf 
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0
[root@localhost network-scripts]# sysctl -p    ##生效
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0

##配置负载分配策略##
[root@localhost ~]#yum -y install ipvsadm
[root@localhost /]# ipvsadm -v
[root@localhost ~]# modprobe ip_vs
[root@localhost ~]# cat /proc/net/ip_vs
[root@localhost ~]#ipvsadm -A -t 192.168.100.100:80 -s rr
[root@localhost ~]#ipvsadm -a -t 192.168.100.100:80 -r 192.168.100.12:80 -g -w 1
[root@localhost ~]#ipvsadm -a -t 192.168.100.100:80 -r 192.168.100.13:80 -g -w 1

[root@localhost network-scripts]# ipvsadm-save
[root@localhost network-scripts]# systemctl enable ipvsadm

存储服务器

[root@localhost ~]# yum -y install nfs-utils
[root@localhost ~]# yum -y install rpcbind
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# vi /etc/exports
/opt/51xit 192.168.100.0/24 (rw,sync)
/opt/52xit 192.168.100.0/24 (rw,sync)
[root@localhost ~]# systemctl restart rpcbind
[root@localhost ~]# systemctl restart nfs
[root@localhost ~]# systemctl enable rpcbind
[root@localhost ~]# systemctl enable nfs
[root@localhost ~]# mkdir /opt/51xit /opt/52xit
[root@localhost ~]# echo "this is 51xit" >/opt/51xit/index.html
[root@localhost ~]# echo "this is 52xit" >/opt/52xit/index.html

web1

##配置ens33:0##
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-lo ifcfg-lo:0
[root@localhost network-scripts]# vi ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.100.10
NETMASK=255.255.255.255
ONBOOT=yes
[root@localhost network-scripts]# ifup lo:0
[root@localhost network-scripts]# ifconfig
[root@localhost network-scripts]# vi /etc/rc.local 
/sbin/route add -host 192.168.100.100 dev lo:0
[root@localhost network-scripts]# route add -host 192.168.100.100 dev lo:0

##调整/proc响应参数##
[root@localhost network-scripts]# vi /etc/sysctl.conf 
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
[root@localhost network-scripts]# sysctl -p

##安装httpd挂载测试页##
[root@localhost ~]# yum -y install nfs-utils
[root@localhost ~]# showmount -e 192.168.100.15     ##如果还没发布,请到存储服务器发布下,exportfs -rv
Export list for 192.168.100.15:
/opt/51xit  (everyone)
/opt/52xit (everyone)
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# mount 192.168.100.15:/opt/51xit /var/www/html/
[root@localhost ~]# vi /etc/fstab 
192.168.100.44:/opt/51xit/ /var/www/html/        nfs     rw,tcp,intr     0 1      ##开机自动挂载,注意格式对齐

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd

##登录192.168.100.12测试网站是否正常##

web2

##配置ens33:0##
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-lo ifcfg-lo:0
[root@localhost network-scripts]# vi ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.100.100
NETMASK=255.255.255.255
ONBOOT=yes
[root@localhost network-scripts]# ifup lo:0
[root@localhost network-scripts]# ifconfig
[root@localhost network-scripts]# vi /etc/rc.local 
/sbin/route add -host 192.168.100.100 dev lo:0
[root@localhost network-scripts]# route add -host 192.168.100.100 dev lo:0

##调整/proc响应参数##
[root@localhost network-scripts]# vi /etc/sysctl.conf 
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
[root@localhost network-scripts]# sysctl -p

##安装httpd挂载测试页##
[root@localhost ~]# yum -y install nfs-utils
[root@localhost ~]# showmount -e 192.168.100.15    ##如果还没发布,请到存储服务器发布下,exportfs -rv
Export list for 192.168.100.15:
/opt/accp  (everyone)
/opt/bdqn (everyone)
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# mount 192.168.100.15:/opt/52xit /var/www/html/
[root@localhost ~]# vi /etc/fstab 
192.168.100.15:/opt/52xit/ /var/www/html/        nfs     rw,tcp,intr     0 1       ##开机自动挂载,注意格式对齐
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd

##登录192.168.100.13测试网站是否正常##

##测试网站192.168.100.100 ##

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值