CentOS7替换yum源时执行yum makecache命令报错

今天重新装Linux虚拟机,配置yum镜像源时候,执行命令 yum makecache时一直报错:
``已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Repository ‘contrib’: Error parsing config: Error parsing “baseurl = ‘http://mirrors.aliyun.com/centos/7Server/contrib/x86_64/\n# http://mirrors.aliyuncs.com/centos/7Server/contrib/x86_64/\n# http://mirrors.cloud.aliyuncs.com/centos/7Server/contrib/x86_64/’”: URL must be http, ftp, file or https not “”
http://mirrors.aliyun.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn’t help to resolve this issue please open a ticket with Red Hat Support.

解决方法

百度了一大圈:才找到了解决办法:

注释掉无法访问的镜像链接

将/etc/yum.repos.d/CentOS-Base.repo(具体名称可能略有差异)文件里面使用的是https://mirrors.aliyuncs.com都注释掉,这个地址是用在阿里云服务器内网的,我们自己的电脑不可能链接得到。

baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
#        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
#        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

指定具体CentOS版本

将/etc/yum.repos.d/CentOS-Base.repo文件中的$releasever直接改为7,如图。
CentOS7替换yum源时执行yum makecache命令报错_第1张图片
希望能帮到大家,所学尚浅,如有错误,欢迎指正!

你可能感兴趣的:(centos,linux)