一、現象
使用yum makecache命令時報錯
[root@MiWiFi-R3L-srv ~]# yum makecache Loaded plugins: fastestmirror Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com http://mirrors.aliyun.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found Trying other mirror. To address this issue please refer to the below wiki article
二、原因
- yum中的變量$releasever是由/etc/yum.conf中的distroverpkg定義的
-
“distroverpkg=centos-release” #將 $releasever設置為centos-release 這個RPM包的版本號
- centos-release是一個rpm包(通過:rpm可以查詢到該軟件包並沒有被安裝)
rpm -q centos-release
三、解決方案
- 由於$releasever無法被識別,無法使用yum安裝,可以修改yum源文件,把$releasever全部替換為7(注意先備份源文件)
- 通過yum安裝centos-release
yum install centos-release -y - 用備份的yum源文件覆蓋修改的yum源文件
參考地址:
https://www.jianshu.com/p/925960eaeb21
https://www.repo.cloudlinux.com/cloudlinux/migrate/release-files/centos/7/x86_64/