使用 Apt-Cacher NG 的 Apt-Get 无法获取哈希值不匹配的软件包

使用 Apt-Cacher NG 的 Apt-Get 无法获取哈希值不匹配的软件包

我有一台机器正在使用在另一台机器上运行的 Apt-Cacher NG 作为缓存代理。

当我尝试运行时sudo apt-get update出现以下错误:

W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_source_Sources  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_binary-amd64_Packages  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_universe_binary-amd64_Packages  Hash Sum mismatch
W: Failed to fetch gzip:/var/lib/apt/lists/partial/it.archive.ubuntu.com_ubuntu_dists_oneiric-updates_main_binary-i386_Packages  Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.

目录 /etc/apt/sources.list.d 是空的。

为了解决这个问题,我已经尝试了以下方法,但没有成功:

解决方案 1:

sudo rm -fr /var/lib/apt/lists
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get autoclean

解决方案 2:

sudo apt-get update -o Acquire::http::No-Cache=True

有什么建议吗?

答案1

我建议放弃 APT-cacher-ng 并检查 Squid-deb-proxy。

事实证明,APT-cacher-ng非常在我看来,它有很多 bug,而且有大量的 bug 报告。直到最近它才建议的现在,一些主要错误已经消除,再次在 Debian 中解锁。对于 Ubuntu,我很久以前就切换到了 Squid-deb-proxy,我并不后悔。它是一个很好的替代方案,也是我遇到的最好的 APT 缓存器。

对于 Squid-deb-proxy,只需安装包squid-deb-proxy并在 中的新文件中添加允许的目标域/etc/squid-deb-proxy/mirror-dstdomain.acl.d。作为奖励,客户端可以通过让squid-deb-proxy-client包已安装。

答案2

您可以立即通过运行以下命令修复此问题:

http://your-cache-server:3142/acng-report.html?abortOnErrors=aOe&byPath=bP&byChecksum=bS&truncNow=tN&incomAsDamaged=iad&purgeNow=pN&doExpire=Start+Scan+and%2For+Expiration&calcSize=cs&asNeeded=an#bottom

这将删除缓存中的所有损坏文件。

要使此永久网络生效,请查看https://www.unix-ag.uni-kl.de/~bloch/acng/html/maint.html#auto-cleanup

基本上,您可以设置每日缓存清理 cron 来对整个缓存进行完整的校验和匹配。这将捕获所有坏的大小和任何其他损坏并清除这些文件。我/etc/cron.daily/apt-cacher-ng在评论后编辑并添加了以下内容:

export ACNGREQ="abortOnErrors=aOe&byPath=bP&byChecksum=bS&truncNow=tN&incomAsDamaged=iad&purgeNow=pN&doExpire=Start+Scan+and%2For+Expiration&calcSize=cs&asNeeded=an"

这相当于点击维护页面上除“跳过标题检查...”之外的所有到期选项

答案3

建议 1

sudo rm /var/lib/apt/lists/*gzip*
sudo rm /var/lib/apt/lists/partial/*gzip*
sudo apt-get update

建议 2

sudo rm -f /var/cache/apt/partial/*
sudo rm -f /var/cache/apt/*.deb
sudo apt-get update

建议 3

sudo touch /etc/apt/apt.conf.d/no-cache
sudo nano /etc/apt/apt.conf.d/no-cache

并将其粘贴到:

Acquire::http {No-Cache=True;};

现在尝试:

sudo apt-get update

答案4

我的升级总是几乎成功——95%的文件将通过代理下载,可能最后约 100 个文件会因“哈希值不匹配”而失败,并且所有提出的解决方案都无法奏效。

然后,只是为了好玩,我转到01proxy01proxy.ng运行aptitude update,然后update-manager选择发行版升级。它继续从archive.ubuntu.com下载剩余的文件(约70M,而不是约1G),其余的升级过程很顺利。重启后,我将01proxy.ng移回01proxy,一切恢复正常。

我已经这样做了两次,一次是在代理服务器上,一次是在客户端上,并且两次在通过代理时失败(在 95% 标记处)后都成功了。

相关内容