在CentOS 5.x 6.x里使用yum源 换阿里云国内源换vault.centos.org源
阿里云CentOS 5 的系统,无法用yum来安装应用软件。
原因:CentOS 5 在2017-03-31日已经结束支持,不再提供维护更新,所以包括阿里云镜像站的文件可能都是过时或已经有部分文件缺失。
2020年11月30日CentOS 6 EOL。按照社区规则,CentOS 6的源地址http://mirror.centos.org/centos-6/
内容已移除,目前第三方的镜像站中均已移除CentOS 6的源。阿里云的源http://mirrors.cloud.aliyuncs.com
和http://mirrors.aliyun.com
也无法同步到CentOS 6的源。当您在阿里云上继续使用默认配置的CentOS 6的源会发生报错。
环境:CentOS 5. X 6.X
方法
1.只保留/etc/yum.repos.d/CentOS-Base.repo 其它文件 要么删除要么改后缀
2.编辑文件 /etc/yum.repos.d/CentOS-Base.repo ,将其中的 mirrors.aliyun.com/centos/$releasever 替换成相应历史源站地址和版本号,
如 vault.centos.org/5.11
[base] name=CentOS-$releasever - Base failovermethod=priority baseurl=http://vault.centos.org/5.11/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates failovermethod=priority baseurl=http://vault.centos.org/5.11/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras failovermethod=priority baseurl=http://vault.centos.org/5.11/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus failovermethod=priority baseurl=http://vault.centos.org/5.11/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib failovermethod=priority baseurl=http://vault.centos.org/5.11/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-5
[base] name=CentOS-$releasever - Base failovermethod=priority baseurl=http://vault.centos.org/6.5/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates failovermethod=priority baseurl=http://vault.centos.org/6.5/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras failovermethod=priority baseurl=http://vault.centos.org/6.5/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus failovermethod=priority baseurl=http://vault.centos.org/6.5/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib failovermethod=priority baseurl=http://vault.centos.org/6.5/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-6
3. 确认在 /etc/yum.repos.d/目录没有除了CentOS-Base.repo之外其他以repo结尾的文件,如果有的话需要删除,然后执行 yum clean all && yum makecache 更新和启用新的yum源。
操作步骤
登录CentOS 6系统的ECS实例。
具体操作,请参见连接方式概述。运行以下命令编辑
CentOS-Base.repo
文件。vim /etc/yum.repos.d/CentOS-Base.repo
按i进入编辑模式,修改以下内容切换源。
请根据实例不同的网络类型进行修改,具体内容如下:编辑完成后,按Esc键,并输入
:wq
保存退出文件。专有网络VPC类型实例
[base] name=CentOS-6.10 enabled=1 failovermethod=priority baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6 [updates] name=CentOS-6.10 enabled=1 failovermethod=priority baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6 [extras] name=CentOS-6.10 enabled=1 failovermethod=priority baseurl=http://mirrors.cloud.aliyuncs.com/centos-vault/6.10/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.cloud.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
运行以下命令编辑
epel.repo
文件。vim /etc/yum.repos.d/epel.repo
按i进入编辑模式,修改以下内容切换源。
请根据实例不同的网络类型进行修改,具体内容如下:编辑完成后,按Esc键,并输入
:wq
保存退出文件。专有网络VPC类型实例
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch enabled=1 failovermethod=priority baseurl=http://mirrors.cloud.aliyuncs.com/epel-archive/6/$basearch gpgcheck=0 gpgkey=http://mirrors.cloud.aliyuncs.com/epel-archive/RPM-GPG-KEY-EPEL-
经典网络类型实例
[epel] name=Extra Packages for Enterprise Linux 6 - $basearch enabled=1 failovermethod=priority baseurl=http://mirrors.aliyuncs.com/epel-archive/6/$basearch gpgcheck=0 gpgkey=http://mirrors.aliyuncs.com/epel-archive/RPM-GPG-KEY-EPEL-6
经典网络类型实例
[base] name=CentOS-6.10 enabled=1 failovermethod=priority baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6 [updates] name=CentOS-6.10 enabled=1 failovermethod=priority baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyuncs.comm/centos-vault/RPM-GPG-KEY-CentOS-6 [extras] name=CentOS-6.10 enabled=1 failovermethod=priority baseurl=http://mirrors.aliyuncs.com/centos-vault/6.10/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6