centos7配置阿里云yum源
原始yum源备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载新的yum源
Centos 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
Centos 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
过程
更新yum缓存
yum clean all
yum makecache
遇到的问题
centos6无法安装
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
http://mirrors.aliyun.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
阿里yum源打开可以看到:
Please keep in mind that 6.0, 6.1, 6.2, 6.3, 6.4 , 6.5, 6.6, 6.7, 6.8 , 6.9 and 6.10 no longer get any updates, nor
any security fix's.
The whole CentOS 6 is *dead* and *shouldn't* be used anywhere at *all*
说明已经不支持centos6 的yum源,因而需要更改为centos7
之后也别再安装centos6了,太老了。。。
centos7 执行yum makecache报错
更改使用centos7的源,发现报出同样的错误,后打开 CentOS-Base.repo文件,发现可能是参数变量的问题:
http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
$releasever 会自动识别centos版本,然后再次找centos6的源
此时将所有变量 $releasever 改为 7(即Centos 7),即可正常访问
相似错误参考
为centos7配置阿里yum源遇到的问题以及解决方法