在 CentOS 上运行的 MinIO 本身不提供内置的带宽/流量限制功能,通常需要通过 系统层或网络层 来限制流量。下面给你几种常见、可用的方案,按推荐程度排序。
tc(Linux 流量控制,推荐)适合:限制 MinIO 监听端口的入站/出站带宽
假设 MinIO 使用端口 9000
# 安装 tc(一般已自带)
yum install -y iproute
# 假设网卡是 eth0
DEV=eth0
# 清除旧规则
tc qdisc del dev $DEV root 2>/dev/null
# 添加根队列
tc qdisc add dev $DEV root handle 1: htb default 10
# 限速类(10Mbps)
tc class add dev $DEV parent 1: classid 1:10 htb rate 10mbit ceil 10mbit
# 限制目标端口 9000 的出站流量
tc filter add dev $DEV protocol ip parent 1:0 prio 1 u32 \
match ip dport 9000 0xffff flowid 1:10
✅ 优点:
❌ 缺点:
nginx 反向代理限速(最常用)适合:HTTP 访问 MinIO
server {
listen 9001;
server_name minio.example.com;
location / {
proxy_pass http://127.0.0.1:9000;
proxy_set_header Host $host;
# 限速 5MB/s
limit_rate 5m;
}
}
✅ 优点:
❌ 缺点:
firewalld + tc(可选)firewalld 本身不能限速,但可配合 tc 使用,适合 CentOS 7/8。
wondershaper(最简单)适合:临时限速整块网卡
yum install -y epel-release
yum install -y wondershaper
# 限制 eth0 上传/下载
wondershaper eth0 10240 10240
✅ 优点:
MinIO 官方 不推荐 在应用层限速
建议使用 负载均衡 / 网关 / 网络策略
| 场景 | 推荐方案 |
|---|---|
| 精确限制 MinIO 端口 | tc |
| HTTP 访问 | nginx limit_rate |
| 临时整机限速 | wondershaper |
| 生产环境 | tc + 开机脚本 |
如果你愿意,可以告诉我:
我可以直接给你一套可复制的配置。