温馨提示×

debian缓存限速如何设

小樊
42
2026-10-13 11:59:54
栏目: 智能运维

在 Debian 里“缓存限速”通常指几种不同场景,下面按常见需求分别说明,你可以对号入座。


一、APT 缓存 / 下载限速(最常用)

1. 限制 apt 下载速度

编辑或新建:

sudo nano /etc/apt/apt.conf.d/95apt-speed

加入:

Acquire
{
    Queue-Mode "host";
    Max-APT-Size "500K";   # 单连接限速
};

或者更简单的方式(临时):

sudo apt -o Acquire::http::Dl-Limit=500 update

单位 KB/s。


二、用代理缓存(apt-cacher-ng)限速

如果你在用 apt-cacher-ng 做局域网缓存:

1. 安装

sudo apt install apt-cacher-ng

2. 限速(通过外部工具)

apt-cacher-ng 本身不内置限速,一般配合 tc 或 wondershaper 对端口限速:

sudo apt install wondershaper
sudo wondershaper eth0 1000 1000   # 下行/上行 1Mbps

三、系统级缓存(如 Squid 代理)限速

如果你用 Squid 做 HTTP 缓存代理:

1. 安装

sudo apt install squid

2. 限速配置

编辑:

sudo nano /etc/squid/squid.conf

加入:

delay_pools 1
delay_class 1 1
delay_parameters 1 64000/64000

含义:64KB/s。


四、磁盘缓存写入限速(如写缓存)

如果是 磁盘 IO 缓存限速(如 rsync、dd):

rsync --bwlimit=1000 src/ dst/

单位 KB/s。


五、用 systemd 限制服务缓存流量(高级)

对某个服务限速:

systemctl set-property apt-daily.service IOBandWidthMax=1M

总结对照表

场景 方法
apt 下载限速 apt.conf
局域网缓存代理 apt-cacher-ng + tc
HTTP 缓存代理 Squid delay_pools
磁盘写入 rsync/dd 限速
服务级 systemd

如果你能说明是 apt / squid / 磁盘 / 网络缓存 哪一种,我可以给你更精确配置。

0 踩