华为交换机基于IP网段配置限速

背景

1
2
3
4
客户私有化TDSQL部署在IDC机房,分布在2个数据中心,DC之间采用专线互通。
TDSQL主要组件有LVS(负载均衡)、Management(管理调度)、DB(DB Engine)、HDFS(DB backup)

DB夜间有备份然后存放到HDFS,HDFS是跨机房高可用部署,所以备份会占用专线带宽。

问题

1
由于在夜间凌晨备份,1G的专线会跑到800M+,客户担心占用太高会影响业务带宽,随之需要限速。

分析

1
2
普通qos限速是针对接入层端口,这样会导致DB服务器所有出入带宽受限。
考虑到只是从DB到跨机房的HDFS传输数据会占用带宽,可针对源目IP进行限速。

配置命令

  • 创建acl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 进入系统视图后操作,sys
[~P-Switch-2]acl 3000
[*P-Switch-2-acl4-advance-3000]rule permit ip source ?
X.X.X.X Address of source
any Any source

# 如果是网段(反掩码),10.230.12.0 0.0.0.255
[*P-Switch-2-acl4-advance-3000]rule permit ip source 10.230.11.13 0 destination 10.230.12.20
[*P-Switch-2-acl4-advance-3000]rule 10 permit ip source 10.230.11.34 0 destination 10.230.12.

[*P-Switch-2-acl4-advance-3000]commit
[~P-Switch-2-acl4-advance-3000]dis th
#
acl number 3000
rule 5 permit ip source 10.230.11.13 0 destination 10.230.12.20 0
rule 10 permit ip source 10.230.11.34 0 destination 10.230.12.20 0
  • 创建感兴趣流

    1
    2
    [~P-Switch-2]traffic classifier hdfs-qos    #创建流分类 
    [*P-Switch-2-classifier-hdfs-qos]if-match acl 3000 #匹配acl
  • 配置策略动作

1
2
3
4
5
6
7
8
[*P-Switch-2]traffic behavior hdfs-qos     #创建流行为
[*P-Switch-2-behavior-hdfs-qos]car cir 665600 pir 665600 #配置流策略做限速,665600 = 650Mbps * 1024

[*P-Switch-2-behavior-hdfs-qos]commit
[~P-Switch-2-behavior-hdfs-qos]dis th
#
traffic behavior hdfs-qos
car cir 665600 kbps pir 665600 kbps
  • 匹配流策略
1
2
3
4
5
6
7
8
[~P-Switch-2]traffic policy hdfs-qos    #创建流策略
[*P-Switch-2-trafficpolicy-hdfs-qos]classifier hdfs-qos behavior hdfs-qos #匹配流分类和流行为

[*P-Switch-2-trafficpolicy-hdfs-qos]commit
[~P-Switch-2-trafficpolicy-hdfs-qos]dis th
#
traffic policy hdfs-qos
classifier hdfs-qos behavior hdfs-qos precedence 5
  • 接口绑定策略
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 查询ip对应的接口
[~P-Switch-2]dis arp | include 10.230.11.13
ARP Entry Types: D - Dynamic, S - Static, I - Interface, O - OpenFlow, RD - Redirect
EXP: Expire-time VLAN: VLAN or Bridge Domain

IP ADDRESS MAC ADDRESS EXP(M) TYPE/VLAN INTERFACE VPN-INSTANCE
----------------------------------------------------------------------------------------
10.230.11.13 5c6f-69cb-b9e1 20 D/11 25GE2/0/7
----------------------------------------------------------------------------------------
Total:19 Dynamic:16 Static:0 Interface:3 OpenFlow:0
Redirect:0

# 进入接口配置
[~P-Switch-2]int 25GE 2/0/7
[~P-Switch-2-25GE2/0/7]traffic-policy hdfs-qos inbound
[*P-Switch-2-25GE2/0/7]commit
[~P-Switch-2-25GE2/0/7]dis th
#
interface 25GE2/0/7
description P-DB-1_11.13
port default vlan 11
traffic-policy hdfs-qos inbound
device transceiver 10GBASE-FIBER
port mode 10G

# 其他接口依照继续绑定策略即可

验证

  • 限速前

  • 限速后

-------------本文结束感谢您的阅读-------------
原创技术分享,感谢您的支持。