当前位置: 首页>>技术教程>>正文


apt-get更新无法获取文件,“临时故障解决…”错误

,

问题描述

Err http://archive.canonical.com natty InRelease    
Err http://security.ubuntu.com oneiric-security InRelease               
Err http://extras.ubuntu.com natty InRelease                            
Err http://security.ubuntu.com oneiric-security Release.gpg
  Temporary failure resolving ‘security.ubuntu.com’
Err http://archive.canonical.com natty Release.gpg
  Temporary failure resolving ‘archive.canonical.com’
Err http://extras.ubuntu.com natty Release.gpg
  Temporary failure resolving ‘extras.ubuntu.com’
Err http://gb.archive.ubuntu.com oneiric InRelease
Err http://gb.archive.ubuntu.com oneiric-updates InRelease
Err http://gb.archive.ubuntu.com natty-backports InRelease
Err http://gb.archive.ubuntu.com oneiric Release.gpg
  Temporary failure resolving ‘gb.archive.ubuntu.com’
Err http://gb.archive.ubuntu.com oneiric-updates Release.gpg
  Temporary failure resolving ‘gb.archive.ubuntu.com’
Err http://gb.archive.ubuntu.com natty-backports Release.gpg
  Temporary failure resolving ‘gb.archive.ubuntu.com’

Reading package lists... Done
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric/InRelease      
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric-updates/InRelease  
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/natty-backports/InRelease  
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/InRelease  
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/natty/InRelease  
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/natty/InRelease  
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/natty/Release.gpg  Temporary failure resolving ‘archive.canonical.com’
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/oneiric-security/Release.gpg  Temporary failure resolving ‘security.ubuntu.com’
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/natty/Release.gpg  Temporary failure resolving ‘extras.ubuntu.com’
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/oneiric-updates/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/natty-backports/Release.gpg  Temporary failure resolving ‘gb.archive.ubuntu.com’
W: Some index files failed to download. They have been ignored, or old ones used instead.

这是我在尝试运行sudo apt-get update时看到的内容。我昨天对我的实例做了更新,现在正在经历这个。

最佳解决方法

overview

您的问题分为两部分:

  • 修复临时解决消息

  • 修复包管理问题

暂时的决心

这个问题很可能是:

  • 由于您的Internet服务提供商未正确将Internet命名(DNS)转发到其或外部DNS服务器,或者

  • 由于您的网络更改同样阻止了此命名 – 例如,新路由器/调制解调器,使用新配置重新配置交换机。

让我们看看可能的DNS解决问题。

首先,临时将已知的DNS服务器添加到您的系统。

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

然后运行sudo apt-get update

如果这样可以修复您的临时解析消息,那么请等待24小时,看看您的ISP是否为您解决了问题(或者只是联系您的ISP) – 或者您可以永久地将DNS服务器添加到您的系统中:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolvconf/resolv.conf.d/base > /dev/null

8.8.8.8是谷歌自己的DNS服务器。

source

您可以使用的另一个示例DNS服务器是OpenDNS – 例如:

echo "nameserver 208.67.222.222" | sudo tee /etc/resolvconf/resolv.conf.d/base > /dev/null

package-management问题

除了临时解决问题 – 你还有一些需要纠正的软件包管理问题 – 我假设你最近尝试过从一个Ubuntu版本升级到下一个推荐版本 – 在你的情况下从Natty(11.04)到Oneiric(11.10)

打开终端并输入

sudo nano /etc/apt/sources.list

查找列表中具有与您期望的不同的分发名称的行 – 在您的情况下 – 您已升级到oneiric但是您有另一个版本名称natty

例如,查找看起来像deb http:/archive.canonical.com/ natty backports的行

例如,将#添加到行的开头以对其进行注释

#deb http:/archive.canonical.com/ natty backports

保存和re-run:

sudo apt-get update && sudo apt-get upgrade

您不应该有任何更多的发布命名错误。

在写这篇的时候,可能的共同release names包括lucidmavericknattyoneiricprecisequantalraringsaucytrustyutopicvivid

次佳解决方法

请注意,这个答案是针对旧版本的Ubuntu编写的。当前版本使用由D-Bus控制的本地名称服务器,此答案的诊断部分适用于此,但不适用于解决方案。如果/etc/resolv.conf含有nameserver 127.0.1.1或更常见的nameserver 127.X.Y.Z,请勿对其进行修改。

“临时故障解决…”表示您的DNS,即从主机名到IP地址的转换不起作用。你最近在机器上重新配置了什么吗?如果不是,这可能是您的ISP的暂时性错误。

ping -n 8.8.8.8显示的行如64 bytes from 8.8.8.8: …吗? (按Ctrl + C停止ping。)

  • 如果没有,则具体存在IP连接问题。运行traceroute -n 8.8.8.8并查看它停止的位置:如果它在您的家中/办公室,请检查您的网络设备。如果您可以联系您的ISP,请向他们投诉。

  • 如果是这样,您特别遇到DNS问题。检查/etc/resolv.conf的内容;应该有一行像nameserver 1.2.3.4(可能不止一个)。如果线路存在,您的ISP内可能存在暂时性问题,您可以通过将nameserver 8.8.8.8添加到该文件来解决此问题(这将声明一个额外的DNS服务器,由Google免费提供)。如果nameserver之后的第一个数字是127,那么您的计算机上有一个DNS中继(这是一件好事),您必须配置该DNS中继而不是修改/etc/resolv.conf。在现代版本的Ubuntu上,默认情况下有一个DNS中继,它是Dnsmasq,它由D-Bus控制。

第三种解决方法

您可以在dir /etc /apt /上找到的文件sources.list中注释未解析的repo

修改sources.list后,清除apt-get仓库为

apt-get clean

然后更新

apt-get update

错误将消失

第四种方法

有时,当您在代理服务器后面时,甚至有必要在/etc/apt/中生成apt.conf文件并使用特定条目填充它,例如:

Acquire::http::proxy "http://<yourproxyserver>:<Port>";
Acquire::https::proxy "http://<yourproxyserver>:<Port>";
Acquire::ftp::proxy "http://<yourproxyserver>:<Port>";

如果需要验证,配置文件如下所示:

Acquire::http::proxy "http://<domain\user>:<password>@<yourproxyserver>:<Port>";
Acquire::https::proxy "http://<domain\user>:<password>@<yourproxyserver>:<Port>";
Acquire::ftp::proxy "http://<domain\user>:<password>@<yourproxyserver>:<Port>";

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/1125.html,未经允许,请勿转载。