Linux - LVS - DR 多网段
2021/7/10 7:06:04
本文主要是介绍Linux - LVS - DR 多网段,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
在上个实验的基础上,给路由,LVS,RS1,RS2 添加172.0.0.0/24网段
1> 路由器
[23:09:10 root@centos8 ~]#ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:18:c0:18 brd ff:ff:ff:ff:ff:ff inet 10.0.0.19/24 brd 10.0.0.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet 172.16.0.200/24 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe18:c018/64 scope link valid_lft forever preferred_lft forever 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:18:c0:22 brd ff:ff:ff:ff:ff:ff inet 192.168.10.50/24 brd 192.168.10.255 scope global noprefixroute eth1 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe18:c022/64 scope link valid_lft forever preferred_lft forever
2> LVS主机
[23:09:27 root@centos8 ~]#ip a a 172.16.0.100/24 dev eth0 [23:10:05 root@centos8 ~]#ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:eb:1f:a3 brd ff:ff:ff:ff:ff:ff inet 10.0.0.16/24 brd 10.0.0.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet 172.16.0.100/24 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:feeb:1fa3/64 scope link valid_lft forever preferred_lft forever
3> RS1,RS2
[23:09:35 root@centos8 ~]#ip a a 172.16.0.100/24 dev eth0 [23:10:14 root@centos8 ~]#ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:e7:af:e9 brd ff:ff:ff:ff:ff:ff inet 10.0.0.17/24 brd 10.0.0.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet 172.16.0.100/24 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fee7:afe9/64 scope link valid_lft forever preferred_lft forever
[23:09:37 root@centos8 ~]#ip a a 172.16.0.100/24 dev eth0 [23:10:19 root@centos8 ~]#ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:8b:5c:39 brd ff:ff:ff:ff:ff:ff inet 10.0.0.18/24 brd 10.0.0.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet 172.16.0.100/24 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe8b:5c39/64 scope link valid_lft forever preferred_lft forever
LVS规则
[22:58:19 root@centos8 ~]#ipvsadm -A -t 172.16.0.100:80 -s rr [23:01:59 root@centos8 ~]#ipvsadm -a -t 172.16.0.100:80 -r 10.0.0.17:80 -g [23:02:34 root@centos8 ~]#ipvsadm -a -t 172.16.0.100:80 -r 10.0.0.18:80 -g [23:02:38 root@centos8 ~]#ipvsadm -Ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 172.16.0.100:80 rr -> 10.0.0.17:80 Route 1 0 0 -> 10.0.0.18:80 Route 1 0 0
测试
[23:10:51 root@centos8 ~]#while :;do curl 172.16.0.100;sleep 1;done 17.noise.org 10.0.0.17 18.noise.org 10.0.0.18 17.noise.org 10.0.0.17 18.noise.org 10.0.0.18 17.noise.org 10.0.0.17 18.noise.org 10.0.0.18 17.noise.org 10.0.0.17 18.noise.org 10.0.0.18
持久保存和重新reload规则 [23:10:07 root@centos8 ~]#ipvsadm-save > /data/ipvsadm-rule1 [23:15:41 root@centos8 ~]#cat /data/ipvsadm-rule1 -A -t centos8.3:http -s rr -a -t centos8.3:http -r 10.0.0.17:http -g -w 1 -a -t centos8.3:http -r 10.0.0.18:http -g -w 1 [23:15:55 root@centos8 ~]#ipvsadm-restore < /data/ipvsadm-rule1 [23:15:59 root@centos8 ~]#ipvsadm -Ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 10.0.0.16:80 rr -> 10.0.0.17:80 Route 1 0 0 -> 10.0.0.18:80 Route 1 0 0
这篇关于Linux - LVS - DR 多网段的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-18git仓库有更新,jenkins 自动触发拉代码怎么配置的?-icode9专业技术文章分享
- 2024-12-18Jenkins webhook 方式怎么配置指定的分支?-icode9专业技术文章分享
- 2024-12-13Linux C++项目实战入门教程
- 2024-12-13Linux C++编程项目实战入门教程
- 2024-12-11Linux部署Scrapy教程:新手入门指南
- 2024-12-11怎么将在本地创建的 Maven 仓库迁移到 Linux 服务器上?-icode9专业技术文章分享
- 2024-12-10Linux常用命令
- 2024-12-06谁看谁服! Linux 创始人对于进程和线程的理解是…
- 2024-12-04操作系统教程:新手入门及初级技巧详解
- 2024-12-04操作系统入门:新手必学指南