- GreatSQL 社区原创内容未经受权不得随便应用,转载请分割小编并注明起源。
- GreatSQL 是 MySQL 的国产分支版本,应用上与 MySQL 统一。
- 什么是 WonderShaper
- 如何装置 WonderShaper
- WonderShaper 应用帮忙
-
WonderShaper 应用示例
- 查看网卡状态
- 限度网卡速度(单位 Kbps)
- 勾销限速
- WonderShaper 在测试中的利用
- 网速单位转换
- 总结
1. 什么是 WonderShaper
WonderShaper 是用来对特定网卡进行疾速限速的工具,它理论是对 linux 的 tc 命令进行封装后的 shell 脚本,所以应用老本比 tc 更低,更容易上手,以下配合测速工具 speedtest 一起应用
2. 如何装置 WonderShaper
# 间接拉取 WonderShaper,开箱即用
git clone https://github.com/magnific0/wondershaper.git
root@****-5491:/home/soft/wondershaper# ./wondershaper -v
Version 1.4.1
root@****-5491:/home/soft/wondershaper#
#网速测试工具 speedtest 装置(Ubuntu)
apt install speedtest-cli
--yum install speedtest-cli (centos)
3.WonderShaper 应用帮忙
root@****-5491:/home/soft/wondershaper# ./wondershaper -h
USAGE: ./wondershaper [-hcs] [-a <adapter>] [-d <rate>] [-u <rate>]
Limit the bandwidth of an adapter
OPTIONS:
-h Show this message【帮忙信息】-a <adapter> Set the adapter【指定网卡接口】-d <rate> Set maximum download rate (in Kbps) and/or【限度下载速度(Kbps)】-u <rate> Set maximum upload rate (in Kbps)【限度上传速度(Kbps)】-p Use presets in "/etc/systemd/wondershaper.conf"
-f <file> Use alternative preset file
-c Clear the limits from adapter【革除指定网卡规定,用于勾销限速】-s Show the current status of adapter【显示以后网卡的状态】-v Show the current version【显示以后版本】Configure HIPRIODST in "/etc/systemd/wondershaper.conf" for hosts
requiring high priority i.e. in case ssh uses dport 443.
MODES:
wondershaper -a <adapter> -d <rate> -u <rate>
wondershaper -c -a <adapter>
wondershaper -s -a <adapter>
EXAMPLES:【应用示例】wondershaper -a eth0 -d 1024 -u 512【设置网卡 eth0 的上行速度为 512kbps,上行速度为 1024kbps】wondershaper -a eth0 -u 512【只设置上行速度为 512kbps】wondershaper -c -a eth0【革除网卡 eth0 的规定】wondershaper -p -f foo.conf【设置指定的配置文件】root@****-5491:/home/soft/wondershaper#
4.WonderShaper 应用示例
4.1 查看网卡状态
root@****-5491:/home/soft/wondershaper# ifconfig eno1
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.5.103 netmask 255.255.255.0 broadcast 192.168.5.255
inet6 fe80::2c93:21f9:1931:304 prefixlen 64 scopeid 0x20<link>
ether c8:f7:50:7e:50:48 txqueuelen 1000 (Ethernet)
RX packets 7748809 bytes 1034513376 (1.0 GB)
RX errors 0 dropped 439 overruns 0 frame 0
TX packets 15528838 bytes 4784318169 (4.7 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0x91500000-91520000
root@****-5491:/home/soft/wondershaper# ./wondershaper -s -a eno1
qdisc fq_codel 0: root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn
Sent 4528052159 bytes 14890189 pkt (dropped 0, overlimits 0 requeues 4224)
backlog 0b 0p requeues 4224
maxpacket 66616 drop_overlimit 0 new_flow_count 35953 ecn_mark 0
new_flows_len 0 old_flows_len 0
-- 测试网速
root@****-5491:/home/soft/wondershaper# speedtest
Retrieving speedtest.net configuration...
Testing from China Telecom (120.36.98.11)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Fuzhou China Mobile,Fujian (Fuzhou) [589.19 km]: 14.449 ms
Testing download speed................................................................................
-- 下载网速是 171.43 Mbit/s,Download: 171.43 Mbit/s
Testing upload speed......................................................................................................
-- 上传网速是 4.15 Mbit/s
Upload: 4.15 Mbit/s
4.2 限度网卡速度(单位 Kbps)
-- 上行 2048kbps=2 Mbit/s, 上行 1024kbps=1 Mbit/s
root@****-5491:/home/soft/wondershaper# ./wondershaper -a eno1 -d 2048 -u 1024
-- 测试网速
root@****-5491:/home/soft/wondershaper# speedtest
Retrieving speedtest.net configuration...
Testing from China Telecom (120.36.98.11)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Far EasTone Telecom (Miaoli City) [722.10 km]: 174.383 ms
Testing download speed................................................................................
-- 上行速度
Download: 1.80 Mbit/s
Testing upload speed......................................................................................................
-- 上行速度
Upload: 1.28 Mbit/s
root@****-5491:/home/soft/wondershaper#
4.3 勾销限速
-- 勾销限速
root@****-5491:/home/soft/wondershaper# ./wondershaper -c -a eno1
-- 查看网卡状态
root@****-5491:/home/soft/wondershaper# ./wondershaper -s -a eno1
qdisc fq_codel 0: root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn
Sent 123022 bytes 471 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
maxpacket 0 drop_overlimit 0 new_flow_count 0 ecn_mark 0
new_flows_len 0 old_flows_len 0
-- 测试网速
root@****-5491:/home/soft/wondershaper# speedtest
Retrieving speedtest.net configuration...
Testing from China Telecom (120.36.98.11)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Far EasTone Telecom (Miaoli City) [722.10 km]: 173.886 ms
Testing download speed................................................................................
Download: 11.29 Mbit/s
Testing upload speed......................................................................................................
Upload: 2.93 Mbit/s
root@****-5491:/home/soft/wondershaper#
5.WonderShaper 在测试中的利用
- 测试项目:某外部数据库迁徙工具
- 测试目标:数据迁徙中,对指标端进行限速,当勾销限速后,传输速度能够复原
-
测试步骤:起迁徙过程,在指标端服务器上用 WonderShaper 工具进行限速:
-- 只限度上行速度 [#22#root@**** ~/wondershaper 14:49:32]22 ./wondershaper -a enp0s3 -d 100
- 测试后果:
限速后,写指标库单位写入行数和单位写入字节数都急剧下降,如下图:
勾销限速,复原网络后,传输速率缓缓复原:
6. 网速单位转换
1KB/s = 8kbps = 8kb/s
比方个别 100M 的宽带,理论是 100Mbps=(100/8) MB/s=12.5 MB/s
7. 总结
应用 WonderShaper 对网卡进行限速,在测试时能够针对性的指定网卡,指定上传速度或者指定下载速度,在测试中上传和下载速度是互不影响的,能够只限度一方;且 WonderShaper 工具操作简略好动手,是个不错的工具。
Enjoy GreatSQL :)
## 对于 GreatSQL
GreatSQL 是由万里数据库保护的 MySQL 分支,专一于晋升 MGR 可靠性及性能,反对 InnoDB 并行查问个性,是实用于金融级利用的 MySQL 分支版本。
相干链接:GreatSQL 社区 Gitee GitHub Bilibili
GreatSQL 社区:
欢送来 GreatSQL 社区发帖发问
https://greatsql.cn/
技术交换群:
微信:扫码增加
GreatSQL 社区助手
微信好友,发送验证信息加群
。