[Centos系统] 2024年最新:配置CentOS 7阿里yum源

749 0
Honkers 2025-10-4 18:26:03 | 显示全部楼层 |阅读模式

前言

根据 CentOS 官方公告,CentOS 7 已经于 2024 年 6 月 30 日结束支持,其软件仓库也相应被上游移除。

阿里云、TUNA等国内镜像站也都移除了各类软件为 CentOS 7(包括 el7, rhel7 或 centos7 等多种变体)提供的版本,因此网上很多设置CentOS 7 YUM源的教程已经不再适用。

不过阿里云、TUNA等国内镜像站也为CentOS 7等官方不再支持的版本提供了历史归档,还在使用CentOS 7的用户可以切换到对应的归档YUM源。

一、备份yum源配置文件

  1. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
复制代码

二、新建阿里云YUM源配置文件

下面将以CentOS 7.9为例配置阿里云yum源,其他版本的CentOS 7可以将配置文件中的7.9.2009全部替换为你使用的系统版本,如:7.8.2003、7.7.1908等

新建yum仓库配置文件

  1. vi /etc/yum.repos.d/CentOS-Base.repo
复制代码

点击i键进入编辑模式,将以下配置信息复制到配置文件中

  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client. You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12. [base]
  13. name=CentOS-$releasever - Base - mirrors.aliyun.com
  14. failovermethod=priority
  15. baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/$basearch/
  16. gpgcheck=1
  17. gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
  18. #released updates
  19. [updates]
  20. name=CentOS-$releasever - Updates - mirrors.aliyun.com
  21. failovermethod=priority
  22. baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/updates/$basearch/
  23. gpgcheck=1
  24. gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
  25. #additional packages that may be useful
  26. [extras]
  27. name=CentOS-$releasever - Extras - mirrors.aliyun.com
  28. failovermethod=priority
  29. baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/extras/$basearch/
  30. gpgcheck=1
  31. gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
  32. #additional packages that extend functionality of existing packages
  33. [centosplus]
  34. name=CentOS-$releasever - Plus - mirrors.aliyun.com
  35. failovermethod=priority
  36. baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/centosplus/$basearch/
  37. gpgcheck=1
  38. enabled=0
  39. gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
  40. #contrib - packages by Centos Users
  41. [contrib]
  42. name=CentOS-$releasever - Contrib - mirrors.aliyun.com
  43. failovermethod=priority
  44. baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/contrib/$basearch/
  45. gpgcheck=1
  46. enabled=0
  47. gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
复制代码

点击Esc键退出编辑模式,输入:wq保存配置文件

三、清除缓存并重建元数据缓存

  1. yum clean all && yum makecache
复制代码


至此阿里云YUM源已经切换成功,可以尽情使用了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行