yum提示“Cannot retrieve metalink for repository: epel/x86_64” 解决方法

今天在centos7服务器上用yum的时候发现,yum命令不能用了,不管用yum什么命令都会出现如下提示:

1、错误提示一:

One of the configured repositories failed (Unknown),and yum doesn't have enough cached data to continue.

中文翻译

其中一个已配置的存储库失败(未知),并且yum没有足够的缓存数据可以继续。

 

2、错误提示二:

Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again

中文翻译

无法检索存储库的metalink:epel / x86_64。 请验证其路径,然后重试

 

3、完整的错误提示如下:

One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again

Cannot retrieve metalink for repository: epel/x86_64.

 

按照网上很多资料都没有解决我的问题,因为:

1、我的服务器 ping 正常的,无论是ping镜像还是ping其它网站都可以ping通。

2、/etc/resolv.conf 里面的 nameserver 114.114.114.114 也是有的,dns也没问题。

 

解决方法

想要解决问题,必须先要找原因,很多人碰上如上图这种错误的时候,都会首先认为是“错误提示一”这个问题,如果这样想,其实就大错特错了。

 

出现此问题,最根本的原因是“/etc/yum.repos.d/epel.repo”里面的镜像源路径不对。

 

既然找到了原因,解决起来就容易多了,具体步骤如下:

 

1、打开 /etc/yum.repos.d/epel.repo

/etc/yum.repos.d/epel.repo

 

2、注释掉mirrorlist,取消注释baseurl

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch

修改为

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch

 

3、再次使用yum命令即正常!

yum clean all
yum makecache
yum update
yum install -y lsof
    A+
发布日期:2019年08月01日 22:38:46  所属分类:Linux
最后更新时间:2019-08-01 22:39:31
评分: (1 票;平均数5.00 ;最高评分 5 ;用户总数1;总得分 5;百分比100.00)
标签:
付杰
PHP运行环境 wamp lamp lnmp 安装 配置 搭建服务
PHP运行环境 wamp lamp lnmp 安装 配置 搭建服务
  • ¥ 9.9元
  • 市场价:49.9元
wordpress站群服务 泛解析二级域名 二级目录站群
wordpress站群服务 泛解析二级域名 二级目录站群
  • ¥ 1999.9元
  • 市场价:4800元
SEO顾问服务 中小型网站 单站/最低99.9元 全方位优化
SEO顾问服务 中小型网站 单站/最低99.9元 全方位优化
  • ¥ 99.9元
  • 市场价:5000元
wp discux 帝国 dedecms phpcms等快速建站
wp discux 帝国 dedecms phpcms等快速建站
  • ¥ 99.9元
  • 市场价:499.9元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: