【Redhat7.0】yum makecache報錯的解決方法(巨坑!!!)
阿新 • • 發佈:2018-12-26
本來是想更換yum源,然後就刪除了linux中 /etc/yum.repos.d除CentOS-Base.repo檔案以外的所有檔案
首先,根據http://mirrors.163.com/.help/centos.html指示備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
然後下載對應版本repo檔案, 放入/etc/yum.repos.d/
我下載的是CentOS7
執行以下命令生成快取
yum clean all
yum makecache
但是執行yum makecache時出現上述錯誤。
然後在網上搜了一通。 試了n個解決方法,都沒有一個對應的。
好幾個小時,終於改好了。
就是把下載的CentOS7對應的repo檔案中的$releasever全部改成對應版本7,並且把不存在的網址的子路徑刪去即可。
修改後如下:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
然後yum makecache生成快取成功!!!
真的是。。