- -了解LVS-DR群集的工作原理
- -会构建LVS-DR负载均衡群集
[root@zw ~]# cd /etc/sysconfig/network-scripts/
[root@zw network-scripts]# cp ifcfg-ens33 ifcfg-ens33:0
[root@zw network-scripts]# vim ifcfg-ens33:0
NAME=ens33:0
DEVICE=ens33:0
ONBOOT=yes
IPADDR=192.168.248.100
NETMASK=255.255.255.255
[root@zw network-scripts]# ifup ifcfg-ens33:0
[root@zw network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.248.78 netmask 255.255.255.0 broadcast 192.168.248.255
inet6 fe80::3a56:a61b:f0f3:fd09 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d9:07:16 txqueuelen 1000 (Ethernet)
RX packets 1342 bytes 143729 (140.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1055 bytes 126013 (123.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.248.100 netmask 255.255.255.255 broadcast 192.168.248.100
ether 00:0c:29:d9:07:16 txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:24:31:78 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@zw network-scripts]#
2. 调整/proc响应参数
- 对于 DR 群集模式来说,由于 LVS 负载调度器和各节点需要共用 VIP 地址,应该关闭 Linux 内核重定向参数响应
- 服务器不是一台路由器,那么它不会发送重定向,所以可以关闭该功能
[root@zw network-scripts]# vim /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@zw 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@zw network-scripts]#
3. 配置负载分配策略
[root@zw ~]# modprobe ip_vs
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
[root@zw ~]# yum -y install ipvsadm
[root@zw ~]# ipvsadm -v
ipvsadm v1.27 2008/5/15 (compiled with popt and IPVS v1.2.1)
[root@zw ~]# [root@zw ~]# ipvsadm -C
[root@zw ~]# ipvsadm -a -t 192.168.248.78:80 -r 192.168.248.88:80 -g -w 1
[root@zw ~]# ipvsadm-save > /etc/sysconfig/ipvsadm
[root@zw ~]# cat /etc/sysconfig/ipvsadm
-A -t www.test.com:http -s rr
-a -t www.test.com:http -r 192.168.248.88:http -g -w 1
[root@zw ~]# systemctl start ipvsadm.service
[root@zw ~]# systemctl enable ipvsadm.service
4. 配置存储服务器192.168.248.215
[root@uuu ~]# yum -y install nfs-utils rpcbind
[root@uuu ~]# mkdir -p /opt/wwwroot
[root@uuu ~]# vim /etc/exports
/opt/wwwroot 192.168.248.0/24(rw,sync,no_root_squash)
[root@uuu ~]# systemctl restart rpcbind
[root@uuu ~]# systemctl restart nfs
5. 配置节点服务器192.168.8.88
[root@uuu ~]# yum -y install httpd
[root@uuu ~]# cd /etc/sysconfig/network-scripts/
[root@uuu network-scripts]# cp ifcfg-lo ifcfg-lo:0
[root@uuu network-scripts]# vim ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.248.78
NETMASK=255.255.255.255
ONBOOT=yes
[root@uuu ~]# yum install -y httpd
[root@uuu ~]# cd /etc/sysconfig/network-scripts/
[root@uuu network-scripts]# cp ifcfg-lo ifcfg-lo:0
[root@uuu network-scripts]# vim ifcfg-lo:0
[root@uuu network-scripts]# ifup lo:0
[root@uuu network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.248.88 netmask 255.255.255.0 broadcast 192.168.248.255
inet6 fe80::fa3a:33a0:cd48:1429 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:89:c9:b0 txqueuelen 1000 (Ethernet)
RX packets 2581 bytes 1205845 (1.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1446 bytes 184056 (179.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo:0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 192.168.248.78 netmask 255.255.255.255
loop txqueuelen 1000 (Local Loopback)
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:30:60:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@uuu network-scripts]#
[root@uuu network-scripts]# vim /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@uuu network-scripts]# 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
[root@uuu network-scripts]#
[root@uuu ~]# showmount -e 192.168.248.215
Export list for 192.168.248.215:
/opt/wwwroot 192.168.248.0/24
[root@uuu ~]# mount 192.168.248.215:/opt/wwwroot /var/www/html
[root@uuu ~]# vim /etc/fstab
192.168.248.215:/opt/wwwroot /var/www/html/ nfs defaults,_netdev 0 0
[root@uuu ~]# systemctl start httpd.service
[root@uuu ~]# systemctl enable httpd.service
然后就可以测试了文章来源地址https://www.toymoban.com/news/detail-794782.html
文章来源:https://www.toymoban.com/news/detail-794782.html
到了这里,关于部署 LVS-DR 群集的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!