问题:

  在本地的虚拟机使用yum安装软件时,经常出现 centos yum (28, 'Connection time-out') Trying other mirror. 或下面的那样情况imeout on http://mirrors.aliyun.com/centos/6/os/x86_64/repodata/repomd.xml: (28, 'Connection time-out') Trying other mirror.

在centOs上安装软件时。提示超时,或链接不上的信息:

http://mirrors.aliyun.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyun.com/centos/6/os/x86_64/repodata/repomd.xml: (28, 'Connection time-out')
Trying other mirror.
http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: (28, 'Connection time-out')
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.cloud.aliyuncs.com'"
Trying other mirror.
http://mirrors.aliyun.com/epel/6/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyun.com/epel/6/x86_64/repodata/repomd.xml: (28, 'Connection time-out')
Trying other mirror.

  当你用排查ping  网络时发现又是通的,浏览器访问链接也是通的。这就奇怪了,为什么yum一安装就说超时报错。换了阿里,网易好几个源都是一个问题,注意了,这可能不是repo源的问题,而是你DNS解析设置的问题。

我们知道网卡的DNS设置是首先生效的 /etc/sysconfig/network-scripts/ifcfg-eth0  然后才是全局的DNS配置文件  /etc/resolv.conf

可能你都都习惯这样设置(在网卡上直接配置外网的DNS解析地址),这样设置在你的公网服务器(如VPS,云服务器等环境)是没有问题的,可当在本地环境(如:虚拟机,本地网络)时就会造成了我们yum安装超时报错。

下面的就是常见不靠谱的DNS配置,

  当你在你的虚拟机网卡设置成外网的DNS,网络好时没事,一不稳定,虚拟机网关在转发请求时,就容易掉,超时就会导致你安装软件失败。

  而本地虚拟机DNS1设置为网关地址,请求通过网关出去会自己找本地的DNS服务器去解析,然后返回给本机。

解决方案:

建议本地虚拟机环境,设置DNS1为网关地址,DNS2 为 223.5.5.5 等其他公网DNS

  

划线的地址要填你自己虚拟机的网关地址。

虚拟机的网关在网卡信息和相应软件的网络管理中可以找到。

我的本地虚拟机常用的DNS设置,可以参考

[root@web- ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE="Ethernet"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
DEVICE="eth0"
ONBOOT="yes"
IPADDR="10.0.0.6"
PREFIX=""
GATEWAY="10.0.0.2"
DNS1=10.0.0.2 # DNS1 设置为网关地址
DNS2=223.5.5.5 #DNS2设置为阿里DNS,或其他的如8.8.8.8 这样网卡的DNS设置就双保险了 [root@web- ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.0.0.2
nameserver 8.8.8.8
 

换源

搞清楚自己的DNS设置后在设置repo源的问题。

注意上面提到的,自己网卡的DNS设置好后!! 然后再换源,不然换完还是超时报错,会很崩溃

这里是CentOS换国内阿里云yum源

1、备份

 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo CentOS
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo CentOS
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、之后运行yum makecache生成缓存

 [root@web02 ~]# yum clean all && yum makecache 
 
 
 
 

yum 报错:centos yum (28, 'Connection time-out') Trying other mirror.的更多相关文章

  1. yum报错 , yum相关配置信息,yum重装

    docker源的问题 yum有很多错,比如网络问题,dns问题,timeout 错,还有不知道什么错误 网上有很多,网络问题,dns问题,但是我ping www.baidu.com通,所以不是这个问题 ...

  2. centOS下yum报错

    CentOS下yum报错 备注:当我们在CentOS下使用yum命令的时候,会报一些错误,一下是我总结的几个解决问题的方法.(保证自己的服务器可以上网) 一.关于Loaded plugins: fas ...

  3. yum报错: Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

    在Centos 5.x或6.x上安装RHEL EPEL Repo repository,资源库,源的意思.RHEL EPEL(Extra Packages for Enterprise Linux)  ...

  4. 运行yum报错Error: Cannot retrieve metalink for reposit

    http://www.netpc.com.cn/593.html 运行yum报错Error: Cannot retrieve metalink for reposit 今天给Centos通过rpm - ...

  5. 转:运行yum报错Error: Cannot retrieve metalink for reposit

    http://www.netpc.com.cn/593.html 运行yum报错Error: Cannot retrieve metalink for repository: epel. Please ...

  6. rhel yum报错

    用yum报错 http://mirrors.aliyun.com/centos/%24releasever/addons/x86_64/repodata/repomd.xml: [Errno 12] ...

  7. yum报错:Error: Multilib version problems found. This often means that the root

    使用yum安装一些依赖库报错: yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel 错误信 ...

  8. 解决yum 不能更新问题 :yum 报错Loaded plugins: fastestmirror, refresh-packagekit, security

    2018-07-02       21:43:13 Yum报错 [root@db yum.repos.d]# yum makecache Loaded plugins: fastestmirror, ...

  9. Centos7.0安装python2.7后yum报错

    yum报错: vi /usr/libexec/urlgrabber-ext-down 把头部的Python改成和/usr/bin/yum中一样的

  10. yum报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:

    原因:学python的时候,把centos7自带的python2.7改成了python3.6.2.而yum使用的是python2,所以会出现yum报错. 解决方法: 在文件/usr/bin/yum./ ...

随机推荐

  1. JVM gc介绍

    Java语言出来之前,大家都在拼命的写C或者C++的程序,而此时存在一个很大的矛盾,C++等语言创建对象要不断的去开辟空间,不用的时候有需要不断的去释放控件,既要写构造函数,又要写析构函数,很多时候都 ...

  2. ntohs, ntohl, htons,htonl的比较和详解【转】

    ntohs =net to host short int 16位 htons=host to net short int 16位 ntohs =net to host long int 32位 hto ...

  3. Haskell语言学习笔记(44)Lens(2)

    自定义 Lens 和 Isos -- Some of the examples in this chapter require a few GHC extensions: -- TemplateHas ...

  4. list接口如何使用

    1集合类,在java语言中的java.util包提供了一些集合类,这些集合类又被称作容器. 2区别集合类和数组.(1)数组的长度是固定的,集合的长度是可变的.(2)数组是用来存放基本数据类型的,集合是 ...

  5. git 使用备忘

    git首次安装后的设置: 首先打开hash.exe输入用户名和邮箱 1 2 $ git config --global user.name "Your Name" $ git co ...

  6. ArcGIS案例学习笔记2_1

    ArcGIS案例学习笔记2_1 联系方式:谢老师,135_4855_4328,xiexiaokui#qq.com 时间:第二天上午 案例1:学校选址 内容:栅格数据分析 教程:pdf page=323 ...

  7. c#数和二叉树

    树(Tree)是 n(n≥0)个相同类型的数据元素的有限集合.树中的数据元素叫结点(Node).n=0 的树称为空树(Empty Tree):对于 n>0 的任意非空树 T 有: (1)有且仅有 ...

  8. express + mongodb 搭建一个简易网站 (三)

    express + mongodb 搭建一个简易网站 (三) 前面已经实现了基本的网站功能,现在我们就开始开搞一个完整的网站,现在整个网站的UI就是下面的这个样子. 我们网站的样子就照着这个来吧. 1 ...

  9. Mysql InnoDB 数据更新 锁表

    一.数据表结构 1 2 3 4 5 6 7 8 9 10 CREATE TABLE `jx_attach` (   `attach_id` int(11) NOT NULL AUTO_INCREMEN ...

  10. like模糊查询

    1. ${}获取值,直接连接 name like '%${search_content}%' 2.CONCAT()函数 MySQL的 CONCAT()函数用于将多个字符串连接成一个字符串,是最重要的m ...