一、配置阿里源
第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
報(bào)錯(cuò):
已加載插件: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; 拒絕連接”
報(bào)錯(cuò)原因:Centos-Base.repo配置文件中的$releasever變量解析錯(cuò)誤,導(dǎo)致整個(gè)URL地址錯(cuò)誤。這種情況一般發(fā)生在Redhat系統(tǒng)安裝Centos源(我的系統(tǒng)是Redhat 7),”http://mirrors.aliyun.com/centos/”,發(fā)現(xiàn)并無(wú) 7Server/目錄。因此,應(yīng)該是$releasever變量解析成了”7Server”,進(jìn)而導(dǎo)致了錯(cuò)誤的發(fā)生,正確的URL地址為 http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml,其中的”7″是指系統(tǒng)版本號(hào)。
三、解決辦法
1.修改yum配置文件
vi /etc/yum.repos.d/CentOS-Base.repo
將全文中所有的 “$releasever” 字符串替換成 “7”,因?yàn)槲业南到y(tǒng)是7版本
輸入 “:” 進(jìn)入末行模式
然后輸入%s/$releasever/7/g
保存并退出
2.再次更新鏡像源
清除yum緩存
yum clean all
生成yum緩存
yum makecache
在修改配置文件后,執(zhí)行yum makecache命令的時(shí)候還是出現(xiàn)了地址無(wú)法訪問(wèn)的報(bào)錯(cuò)信息,其實(shí)這個(gè)并不影響。如果不想看到報(bào)錯(cuò)信息的話,把a(bǔ)liyuncs部分信息刪掉就可以了。