yum源中$releasever不能被系统识别
一、现象
使用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/
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步