- 首先備份
/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- 進(jìn)入yum源配置文件所在文件夾
[root@localhost yum.repos.d]# cd /etc/yum.repos.d/
- 下載163的yum源配置文件君纫,放入/etc/yum.repos.d/(操作前請(qǐng)做好相應(yīng)備份)
[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)
- 運(yùn)行yum makecache生成緩存
[root@localhost yum.repos.d]# yum makecache
- 更新系統(tǒng)
[root@localhost yum.repos.d]# yum -y update
錯(cuò)誤總結(jié):
- Cannot retrieve metalink for repository: epel…錯(cuò)誤解決辦法
RHEL6下yum -y install epel-release安裝了epel源,但yum makecache出錯(cuò)窍箍。
centos下安裝完EPEL源然后更新一下yum緩存如果發(fā)現(xiàn)這樣的錯(cuò)誤:
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
這就表明你需要更新CA證書了拷窜,那么只需要更新CA證書就可以,不過(guò)在此同時(shí)需要臨時(shí)禁用epel源并更新就可以了锡足,命令如下:
yum --disablerepo=epel -y update ca-certificates
- [yum安裝時(shí)出現(xiàn):Cannot retrieve metalink for repository: epel. Please verify its path and try again]
在CentOS下安裝出現(xiàn)了問(wèn)題:Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again,需要安裝epel源限番。
解決方法: 一句話:把/etc/yum.repos.d/epel.repo舱污,文件第3行注釋去掉,把第四行注釋掉弥虐。具體如下:
打開(kāi)/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服務(wù):service network restart
參考:(https://www.cnblogs.com/dadong616/p/5062727.html)
(https://www.cnblogs.com/shenlanzhizun/p/7683166.html)