EC2 Ubuntu 14.04 实例:运行“apt-get update”导致“哈希总和不匹配”

EC2 Ubuntu 14.04 实例:运行“apt-get update”导致“哈希总和不匹配”

每次我使用 Ubuntu 14.04 创建新的 AWS EC2 实例时(使用ami-a182b391,如从这里),然后立即运行sudo apt-get -y update,结果出现了错误。

这是操作系统信息:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:    14.04
Codename:   trusty

这是失败的 apt 命令:

$ sudo apt-get -y update
Ign http://us-west-2.ec2.archive.ubuntu.com trusty InRelease
Ign http://us-west-2.ec2.archive.ubuntu.com trusty-updates InRelease
Hit http://us-west-2.ec2.archive.ubuntu.com trusty Release.gpg
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates Release.gpg
Hit http://us-west-2.ec2.archive.ubuntu.com trusty Release
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates Release             
Get:1 http://us-west-2.ec2.archive.ubuntu.com trusty/main Sources [1,064 kB]   
Get:2 http://us-west-2.ec2.archive.ubuntu.com trusty/universe Sources [6,399 kB]
Ign http://security.ubuntu.com trusty-security InRelease                       
Get:3 http://security.ubuntu.com trusty-security Release.gpg [933 B]           
Get:4 http://security.ubuntu.com trusty-security Release [63.5 kB]             
Hit http://us-west-2.ec2.archive.ubuntu.com trusty/main amd64 Packages         
Hit http://us-west-2.ec2.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://us-west-2.ec2.archive.ubuntu.com trusty/main Translation-en
Hit http://us-west-2.ec2.archive.ubuntu.com trusty/universe Translation-en     
Get:5 http://us-west-2.ec2.archive.ubuntu.com trusty-updates/main Sources [196 kB]
Get:6 http://us-west-2.ec2.archive.ubuntu.com trusty-updates/universe Sources [114 kB]
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates/main amd64 Packages 
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://us-west-2.ec2.archive.ubuntu.com trusty/main Translation-en_US     
Ign http://us-west-2.ec2.archive.ubuntu.com trusty/universe Translation-en_US 
Get:7 http://security.ubuntu.com trusty-security/main Sources [80.3 kB]       
Get:8 http://security.ubuntu.com trusty-security/universe Sources [21.9 kB]  
Get:9 http://security.ubuntu.com trusty-security/main amd64 Packages [267 kB]  
Get:10 http://security.ubuntu.com trusty-security/universe amd64 Packages [101 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en    
Fetched 8,308 kB in 4s (1,678 kB/s)               
W: Failed to fetch http://us-west-2.ec2.archive.ubuntu.com/ubuntu/dists/trusty-updates/main/source/Sources  Hash Sum mismatch

W: Failed to fetch http://us-west-2.ec2.archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/source/Sources  Hash Sum mismatch

E: Some index files failed to download. They have been ignored, or old ones used instead.

除了启动它并运行这个命令之外,我实际上没有在该盒子上做任何其他事情,并且我尝试了多个实例,但这种情况总是发生。

我找到了一个解决方法:

$ sudo rm -rf /var/lib/apt/lists/
$ sudo apt-get -y update
Ign http://us-west-2.ec2.archive.ubuntu.com trusty InRelease
Ign http://us-west-2.ec2.archive.ubuntu.com trusty-updates InRelease
Get:1 http://us-west-2.ec2.archive.ubuntu.com trusty Release.gpg [933 B]
Get:2 http://us-west-2.ec2.archive.ubuntu.com trusty-updates Release.gpg [933 B]
...
Get:23 http://security.ubuntu.com trusty-security/main Translation-en [136 kB]
Get:24 http://security.ubuntu.com trusty-security/universe Translation-en [56.8 kB]
Fetched 21.9 MB in 5s (3,724 kB/s)                                 
Reading package lists... Done

但是 1)为什么会发生这个错误,2)这种解决方法“可以”吗?

答案1

相关帖子包含一些答案和相关的错误报告。

https://askubuntu.com/questions/41605/trouble-downloading-packages-list-due-to-a-hash-sum-mismatch-error

https://bugs.launchpad.net/ubuntu/+source/apt/+bug/972077

TLDR;1)这是亚马逊镜像的问题;2)这是一种常见的解决方法,一般被认为“可以”但很烦人。

答案2

我向 AWS 提交了支持请求,问题已不再发生。我相信他们已经更新/修复了一些软件包。

答案3

安全组 -> 出站

*   ALL Traffic ALL     ALL     0.0.0.0/0   Allow

如果您想连接到外部服务器(如 google.com)或甚至想要更新,请允许出站 - sudo apt-get update

您可以使用 AWS 前端转到“安全组”->“出站”来允许出站

确保为你的 AWS 实例选择正确的组

相关内容