当然可以。以下是按照您的要求整理的表格形式的实验手册:
主机名称 | 网卡信息 | 安装应用 | 系统 |
---|---|---|---|
Client客户端 | 192.168.2.101 | 无 | RHEL8/CentOS8 |
Lvs服务器(DR) | DIP:192.168.2.110 VIP:192.168.40.111 | ipvsadm | RHEL8/CentOS8 |
RS1 | RIP:192.168.2.111 | httpd | RHEL8/CentOS8 |
RS2 | RIP:192.168.2.112 | httpd | RHEL8/CentOS8 |
这里的每个主机都有其特定的功能和配置:
- Client客户端:用于发起请求。
- Lvs服务器(DR):作为负载均衡器,负责接收和分发流量。
- RS1 和 RS2:作为真实服务器,处理来自负载均衡器的请求。
负载均衡器 (LB)
-
保存 IPVS 配置:
shipvsadm --save > /etc/sysconfig/ipvsadm
-
启用 IP 转发:
shecho "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf sysctl -p
-
配置 TUN 接口:
shifconfig tunl0 192.168.2.200 broadcast 192.168.2.200 netmask 255.255.255.255 up
-
创建虚拟服务器并设置轮询调度:
shipvsadm -A -t 192.168.2.200:80 -s rr
-
添加真实服务器:
shipvsadm -a -t 192.168.2.200:80 -r 192.168.2.111:80 -i ipvsadm -a -t 192.168.2.200:80 -r 192.168.2.112:80 -i
-
禁用防火墙与 SELinux:
shsystemctl stop firewalld.service setenforce 0
-
验证 IPVS 配置:
shipvsadm -ln
真实服务器 1 (RS1)
-
启动 HTTP 服务:
shsystemctl start httpd
-
禁用 SELinux 和防火墙:
shsetenforce 0 systemctl stop firewalld.service
-
配置网站内容:
shecho "this is web1" >> /var/www/html/index.html
-
测试网站:
shcurl 127.0.0.1
-
配置 TUN 接口:
shifconfig tunl0 192.168.2.200 broadcast 192.168.2.200 netmask 255.255.255.255 up
-
调整 sysctl 设置:
shecho "net.ipv4.conf.tunl0.arp_ignore = 1" >> /etc/sysctl.conf echo "net.ipv4.conf.tunl0.arp_announce = 2" >> /etc/sysctl.conf echo "net.ipv4.conf.all.arp_ignore = 1" >> /etc/sysctl.conf echo "net.ipv4.conf.all.arp_announce = 2" >> /etc/sysctl.conf echo "net.ipv4.conf.tunl0.rp_filter = 0" >> /etc/sysctl.conf echo "net.ipv4.conf.all.rp_filter = 0" >> /etc/sysctl.conf sysctl -p
真实服务器 2 (RS2)
-
启动 HTTP 服务:
shsystemctl start httpd
-
禁用 SELinux 和防火墙:
shsetenforce 0 systemctl stop firewalld.service
-
配置网站内容:
shecho "this is web2" >> /var/www/html/index.html
-
测试网站:
shcurl 127.0.0.1
-
配置 TUN 接口:
shifconfig tunl0 192.168.2.200 broadcast 192.168.2.200 netmask 255.255.255.255 up
-
调整 sysctl 设置:
shecho "net.ipv4.conf.tunl0.arp_ignore = 1" >> /etc/sysctl.conf echo "net.ipv4.conf.tunl0.arp_announce = 2" >> /etc/sysctl.conf echo "net.ipv4.conf.all.arp_ignore = 1" >> /etc/sysctl.conf echo "net.ipv4.conf.all.arp_announce = 2" >> /etc/sysctl.conf echo "net.ipv4.conf.tunl0.rp_filter = 0" >> /etc/sysctl.conf echo "net.ipv4.conf.all.rp_filter = 0" >> /etc/sysctl.conf sysctl -p
测试
-
测试负载均衡器:
shcurl 192.168.2.200
sh[root@localhost ~]# curl 192.168.2.200 this is web2 [root@localhost ~]# curl 192.168.2.200 this is web1 [root@localhost ~]# curl 192.168.2.200 this is web2 [root@localhost ~]# curl 192.168.2.200 this is web1 [root@localhost ~]# curl 192.168.2.200 this is web2 [root@localhost ~]# curl 192.168.2.200 this is web1 [root@localhost ~]# curl 192.168.2.200 this is web2 [root@localhost ~]# curl 192.168.2.200 this is web1