yum源中$releasever不能被系统识别

服务器yum操作报错
http://mirrors.cloud.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

$releasever变量没有被系统识别,查看rpm -q centos-release,结果package centos-release is not installed,此包没有安装。

解决方法:
  1. 修改/etc/yum.repos.d/CentOS-Base.repo$releasever为对应的系统版本路径,比如centos7就改为7

    如:

    [base]
    name=CentOS-7
    enabled=1
    failovermethod=priority
    baseurl=http://mirrors.cloud.aliyuncs.com/centos/7/os/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.cloud.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7
    
    [updates]
    name=CentOS-7
    enabled=1
    failovermethod=priority
    baseurl=http://mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.cloud.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7
    
    [extras]
    name=CentOS-7
    enabled=1
    failovermethod=priority
    baseurl=http://mirrors.cloud.aliyuncs.com/centos/7/extras/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.cloud.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7
    
    

    2.安装 yum install centos-release,在/etc/yum.repos.d生成了新的源文件CentOS-Base.repo.rpmnew,修改覆盖之前的文件mv CentOS-Base.repo.rpmnew CentOS-Base.repo$releasever就可以正常解析了。

番外:

查看系统版本命令:

lsb_release -a

vim全局替换命令:

:%s/$releaserver/7/g
:{作用范围}s/{目标}/{替换}/{替换标志}
参考:

vim https://harttle.land/2016/08/08/vim-search-in-file.html

系统版本 https://www.qiancheng.me/post/coding/show-linux-issue-version

yum https://www.jianshu.com/p/925960eaeb21

你可能感兴趣的:(yum源中$releasever不能被系统识别)