问题:

  在本地的虚拟机使用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. 下载的chm文件打不开问题

    下载的chm文件无法打开,是因为此文件是在其它电脑上编辑的,上面留有原电脑的信息,当下载打开时,发现电脑信息不一致,因此会将应用锁定. 操作:文件  -->  属性  -->常规 --&g ...

  2. chrome 设置是否缓存

    在进行本地开发时,因老需要修改js,css等文件,而页面又带有缓存因此无法自动更新为新的文件. 在页面点击 -> F12 ->F1 ->References -> NetWor ...

  3. UI5-文档-4.4-XML Views

    将所有UI放到index.html文件将很快导致一个混乱的设置,有相当多的工作在我们前面.我们先用sap.m.Text进行模块化.控件导入专用视图. SAPUI5支持多种视图类型(XML.HTML.J ...

  4. windows下的java项目打jar分别编写在windows与linux下运行的脚本( 本人亲测可用!)

    前言: 最近公司做了一个工具,要将这个工具打包成一个可运行的程序,编写start.bat和start.sh在windows和linux下都可以运行. 在网上找了很多资料,最后终于找到一个可靠的资料,记 ...

  5. Get与Post提交方式的区别

    用 curl 测试 post 请求: curl -d   "agentCode=RB&startDate=2017-07-01&endDate=2017-09-01& ...

  6. 【336】Tutorial of Endnote

    Now I start to use Endnote to manage my literatures and I need to learn how to use it. Below is some ...

  7. redmine邮件配置

    网上找了半天,有很多答案,最后自己测试找出一个解决办法. 1.找到安装位置 D:\Bitnami\redmine-2.5.2-2\apps\redmine\htdocs\config下的文件confi ...

  8. SQL 变量、 运算符、 if 、while

    变量: SQL语言也跟其他编程语言一样,拥有变量.分支.循环等控制语句. 在SQL语言里面把变量分为局部变量和全局变量,全局变量又称系统变量. 局部变量: 使用declare关键字给变量声明,语法非常 ...

  9. (mac环境)Appium安装了client包,但是提示no module named appium

    背景 mac环境,使用pip install Appium-Python-Client已经安装了client包   问题 import appium,提示no module named appium ...

  10. .net 委托的用法

    定义了两个委托 //Func有返回值:Action无返回值.两个委托 Func<int,int> f= a =>a+1;//参数,返回值: int reslut=f(5);//6