文章目录 「隐藏」
前言
根据 CentOS 官方声明,CentOS 7 的支持已于 2024 年 6 月 30 日正式终止,伴随而来的是软件仓库从上游的移除。
国内镜像站如阿里云、 TUNA 等已同步下架了 CentOS 7(涵盖 el7 、 rhel7 及 centos7 等版本)的软件包,导致多数现有 YUM 源配置教程失效。
尽管如此,这些镜像站为维持用户过渡,提供了 CentOS 7 等停服版本的历史归档服务,允许继续使用该系统的用户切换至相应的归档 YUM 源以维持操作。
一、备份 yum 源配置文件
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 仓库配置文件
vi /etc/yum.repos.d/CentOS-Base.repo
点击 i 键进入编辑模式,将以下配置信息复制到配置文件中
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
点击 Esc 键退出编辑模式,输入:wq 保存配置文件
三、清除缓存并重建元数据缓存
yum clean all && yum makecache
至此阿里云 YUM 源已经切换成功,可以尽情使用了
《2024年最新:配置CentOS 7阿里yum源》留言数:0