zoukankan      html  css  js  c++  java
  • apt-get update 更新 ubuntu时出现Hash sum mismatch的原因及解决方法

    $ sudo apt-get update

    ......
    Hit http://mirrors.163.com trusty/main Sources                                 
    Hit http://mirrors.163.com trusty/restricted Sources                           
    Get:17 http://mirrors.163.com trusty/universe Sources [6,399 kB]               
    Hit http://mirrors.163.com trusty/multiverse Sources                           
    Err http://mirrors.163.com trusty-security/main i386 Packages                  
      404  Not Found [IP: 123.58.190.235 80]
    Fetched 41.0 MB in 1min 3s (643 kB/s)                                          
    W: Failed to fetch http://mirrors.163.com/ubuntu/dists/trusty-security/main/binary-amd64/Packages  Hash Sum mismatch
    W: Failed to fetch http://mirrors.163.com/ubuntu/dists/trusty-security/main/binary-i386/Packages  404  Not Found [IP: 123.58.190.235 80]
    W: Failed to fetch http://mirrors.163.com/ubuntu/dists/trusty-security/restricted/binary-i386/Packages  Hash Sum mismatch
    W: Failed to fetch http://mirrors.163.com/ubuntu/dists/trusty-updates/restricted/source/Sources  Hash Sum mismatch
    W: Failed to fetch http://mirrors.163.com/ubuntu/dists/trusty-updates/main/binary-amd64/Packages  Hash Sum mismatch
    W: Failed to fetch http://mirrors.163.com/ubuntu/dists/trusty-updates/restricted/binary-amd64/Packages  Hash Sum mismatch

    ......

    我估计很多人遇到过此问题,搜索半天发现国内所有中文描述此问题的解决方案的没有一个是靠谱可用的。

    随查询英文,方得到正解,为了避免更多人疑惑,很少发帖的我决定把此问题的真正原因告知大家。

    先引用 askubuntu.com上面关于此问题的原文解释,

    给出正解的人叫做Robie Basak

    引用:
    This is a known issue, and is exacerbated for clients behind proxy caches. Some large organisations and ISPs (especially in remote parts of the world) have transparent caches of which you may not be aware.

    The fundamental issue is that the apt repository format is subject to race conditions when a mirror is updated. This problem particularly affects repositories that change rapidly, such as the development release.

    You can track progress on the fix for this in this bug (please mark yourself as "affects me too" in the bug) and this blueprint. But be aware that it is a complex issue and may take more than one release to resolve.
    shareimprove this answer

    answered Jul 5 '12 at 22:21



    大意是:

    你所使用的网络供应商,有些会设置一些透明缓存,以增加网络内部速度,减少出口的流量,你获取的某些文件不是源服务器上的真正文件,是从缓存中获取的,当缓存中获取的一些校验信息跟源中不一致的时候,自然提示校验失败,无法继续更新。

    此问题实际上跟apt软件仓库的格式设计有关。新发布的版本的软件仓库更新比较频繁,按道理缓存中的文件应该同步更新,可惜因为多个镜像站点的有快慢,因此造成了缓存无法保证一致性。
    当网络提供商足够有实力,不设至透明缓存时,这个问题是不存在的。这就是为什么有些人反馈使用无线上网卡(移动、联通的3g网络)就一切OK,一单换回长城宽带、或者宽带通就不行了。

    以上就是问题出现的真正原因。

    我的家中网络是宽带通,毫无疑问这种网络ISP肯定会设置透明缓存。
    解决方案很简单,绕过缓存直接访问站点即可。
    如何绕过ISP设置的这种缓存,方法跟绕过长城防火墙一样。
    我找了个免费的 ssh 服务代理,
    再安装一个 proxychains,在 /etc/proxychians.conf 中设置好你的代理
    使用 proxychains sudo apt-get update

    更新正常(无论你更新哪一个源,国内或国外)

    如果你觉得代理不够快,只要更新完源索引,安装软件时直接 sudo apt-ge install xxx,即可。在软件中心中安装各类软件也没问题。


    这问题根本解决跟 apt repository 的格式设计有关。
    不过欧美的 ISP 似乎网络足够好,设置缓存的较少,反正提此问题的人并不多。因此他们是不是会进行改进设计真是无法预知。

    还有一种情况会自然解决,就是等源索引渐渐稳定下来后,你的 ISP 的缓存也就跟真实数据保持一致了,此时更新就自然没问题。
    新版本发布时更新肯定很频繁,估计大部分新版控无法等待。


    以上就是关于引起更新源索引时 Hash Sum mismatch 问题的真正原因,以及解决方案,希望对各位朋友有所帮助。

  • 相关阅读:
    当你开始学习编程时,你最希望知道什么?我想起来的只有27件事!
    神父说,要有光,要有码农,于是十大天神创造了宏大的编程界!
    我今天就要说HTML它就是一门编程语言!只有外行才说它是超文本标记语言!
    【源码分享】用C++实现通讯录管理系统!功能齐全,实属精品!
    虎牙员工自曝被公司HR带着五个人抬出公司扔到门外!虎牙回应:他简历造假!
    C与C++的互相调用!就像大学宿舍一样,我用你的,你用我的!
    为什么你的简历总会石沉大海!一定要真实,切勿造假!
    Python3列表
    Python3元组
    线程回收
  • 原文地址:https://www.cnblogs.com/gaowengang/p/7398100.html
Copyright © 2011-2022 走看看