Redhat7系统配置阿里源失败问题及解决办法

如题所述

一、配置阿里源

第1步: 下载阿里源的配置文件

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

第2步: 更新镜像源

清除yum缓存

yum clean all

生成yum缓存

yum makecache

报错:

已加载插件:langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

http://mirrors.aliyun.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

正在尝试其它镜像。

http://mirrors.aliyuncs.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; 拒绝连接"

报错原因: Centos-Base.repo配置文件中的$releasever变量解析错误,导致整个URL地址错误。这种情况一般发生在Redhat系统安装Centos源(我的系统是Redhat 7), " http://mirrors.aliyun.com/centos/ ",发现并无 7Server/目录。因此,应该是$releasever变量解析成了"7Server",进而导致了错误的发生,正确的URL地址为 http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml ,其中的"7"是指系统版本号

三、解决办法

1.修改yum配置文件

vi /etc/yum.repos.d/CentOS-Base.repo

将全文中所有的 "$releasever" 字符串替换成 "7",因为我的系统是7版本

输入 ":" 进入末行模式

然后输入%s/$releasever/7/g

保存并退出

2.再次更新镜像源

清除yum缓存

yum clean all

生成yum缓存

yum makecache

在修改配置文件后,执行yum makecache命令的时候还是出现了地址无法访问的报错信息,其实这个并不影响。如果不想看到报错信息的话,把aliyuncs部分信息删掉就可以了。

温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜