:配置CentOS 7阿里yum源

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

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

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

一、备份yum源配置文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
1
二、新建阿里云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
1
点击i键进入编辑模式,将以下配置信息复制到配置文件中

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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.3.1611/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.3.1611/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.3.1611/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.3.1611/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.3.1611/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
1

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


:配置CentOS 7阿里yum源
http://wizhiai.github.io/p/7b1cd0a0544e43a6827bf9e453304786/
作者
胡礼节
发布于
2024年12月13日
许可协议