当前位置:首页 > 技术分享 > 正文内容

在CentOS 5.x 6.x里使用yum源 换阿里云国内源换vault.centos.org源

admin4年前 (2021-04-14)技术分享3926

阿里云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.comhttp://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源。

操作步骤



  1. 登录CentOS 6系统的ECS实例。

    具体操作,请参见连接方式概述
  2. 运行以下命令编辑CentOS-Base.repo 文件。

    vim /etc/yum.repos.d/CentOS-Base.repo
  3. 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

    经典网络类型实例

    [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
  4. 运行以下命令编辑epel.repo 文件。

    vim /etc/yum.repos.d/epel.repo
  5. 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

扫描二维码推送至手机访问。

版权声明:本文由小刚刚技术博客发布,如需转载请注明出处。

本文链接:http://blog.bitefu.net/post/159.html

分享给朋友:

相关文章

php Aes 加密模式ECB填充pkcs5padding base64

最近做支付项目用到了aes加密不过试了好多办法总是和官方给出的结果不一样,找了很久终于找到了测试结果同 http://tool.chacuo.net/cryptaes/ <?php /**  * [Aes&nb...

七牛html js上传带进度条源码

七牛html js上传带进度条源码注册链接https://s.qiniu.com/uM7RJv完整代码下载:https://n802.com/f/349707-489018989-c141f6(访问密码:5036)http://www.yi...

安卓模拟器连接端口 及常用命令

下面是我总结和测试通过的:有的是搜集来的模拟器名称                     &nbs...

抢先体验太阳谷!20H1、20H2、21H1替换“Dev版新图标”

尽量不要替换shell32.dll.mun和zipfldr.dll.mun,这两老哥可能会带来无法预测的风险!不解除被替换文件的硬链接,已确定会导致无法安装质量更新!(详见H大测评)单替换imageres.dll.mun新图标覆盖率基本可达...

apicloud影视APP源码 无需后台

apicloud影视APP源码 无需后台

介绍集合vip影视接口到一个android app中 方便观看各平台影视资源及直播开源地址:https://gitee.com/web/vip_yingshi软件架构使用apicloud搭建影视APP源码,无后台,调用接口同步api解析网址...

[钉钉]内网穿透之HTTP穿透

[钉钉]内网穿透之HTTP穿透

内网穿透之HTTP穿透更新时间:2021-06-21鉴于很多开发者在临时体验开发时往往没有公网域名或者公网IP,本工具提供了一个公网代理服务,目的是方便开发测试。注意 本工具不保证稳定性,仅适用于开发测试阶段,禁止当作公网域名使用...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。