centos7更新yum源和遇到的问题

  • 首先备份

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

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

  • 进入yum源配置文件所在文件夹

[root@localhost yum.repos.d]# cd /etc/yum.repos.d/

  • 下载163的yum源配置文件,放入/etc/yum.repos.d/(操作前请做好相应备份)

[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

(CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo)

  • 运行yum makecache生成缓存

[root@localhost yum.repos.d]# yum makecache

  • 更新系统

[root@localhost yum.repos.d]# yum -y update

错误总结:

  • Cannot retrieve metalink for repository: epel…错误解决办法
    RHEL6下yum -y install epel-release安装了epel源,但yum makecache出错。

centos下安装完EPEL源然后更新一下yum缓存如果发现这样的错误:
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
这就表明你需要更新CA证书了,那么只需要更新CA证书就可以,不过在此同时需要临时禁用epel源并更新就可以了,命令如下:

yum --disablerepo=epel -y update ca-certificates
  • [yum安装时出现:Cannot retrieve metalink for repository: epel. Please verify its path and try again]

在CentOS下安装出现了问题:Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again,需要安装epel源。

解决方法: 一句话:把/etc/yum.repos.d/epel.repo,文件第3行注释去掉,把第四行注释掉。具体如下:

打开/etc/yum.repos.d/epel.repo,将

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch

baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
修改为

[epel]
name=Extra Packages for Enterprise Linux 6 - basearch

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

再清理源,重新安装

yum clean all
yum install -y 需要的包

如果还是不行,修改DNS,到/etc/resolv.conf下添加一下:

nameserver 8.8.8.8
search localdomain

然后重启network服务:service network restart

参考:(https://www.cnblogs.com/dadong616/p/5062727.html)
(https://www.cnblogs.com/shenlanzhizun/p/7683166.html)

你可能感兴趣的:(centos7更新yum源和遇到的问题)