在 Debian 里“缓存限速”通常指几种不同场景,下面按常见需求分别说明,你可以对号入座。
编辑或新建:
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 做局域网缓存:
sudo apt install apt-cacher-ng
apt-cacher-ng 本身不内置限速,一般配合 tc 或 wondershaper 对端口限速:
sudo apt install wondershaper
sudo wondershaper eth0 1000 1000 # 下行/上行 1Mbps
如果你用 Squid 做 HTTP 缓存代理:
sudo apt install squid
编辑:
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。
对某个服务限速:
systemctl set-property apt-daily.service IOBandWidthMax=1M
| 场景 | 方法 |
|---|---|
| apt 下载限速 | apt.conf |
| 局域网缓存代理 | apt-cacher-ng + tc |
| HTTP 缓存代理 | Squid delay_pools |
| 磁盘写入 | rsync/dd 限速 |
| 服务级 | systemd |
如果你能说明是 apt / squid / 磁盘 / 网络缓存 哪一种,我可以给你更精确配置。