1. Back up the current yum source configuration file
Enter /dev/yum.repos.d
the directory to back up the source configuration files in this directory:
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bk/
[root@localhost yum.repos.d]# mv * bk/
2. Download the source configuration file
Use wget
the command to download the mirror source of the corresponding system from Alibaba Cloud, here is the author's CentOS 8
.
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
The output is as follows (if you see the download 100%
, it means there is no problem):
--2022-11-27 20:27:27-- http://mirrors.aliyun.com/repo/Centos-8.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 39.173.101.99, 39.173.101.105, 39.173.101.104, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|39.173.101.99|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2590 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
/etc/yum.repos.d/CentOS-Base. 100%[=================================================>] 2.53K --.-KB/s 用时 0.04s
2022-11-27 20:27:27 (61.4 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2590/2590])
3. Modify the yum source configuration file
Open the configuration file you just downloaded, and you need to make some simple modifications.
[root@localhost yum.repos.d]# vim /etc/yum.repos.d/CentOS-Base.repo
Use to enter the command mode after vim
opening the file :
( vim
press first after opening the file Esc
, then press Shift + :
to enter the command mode), enter the following command, and mirrors.cloud.aliyuncs.com
replace with mirrors.aliyun.com
.
%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g
Then enter the command mode again, enter the following command, and $releasever
replace $releasever-stream
.
%s/$releasever/$releasever-stream/g
4. Update the yum source configuration file
Execute the following command to clear yum
the cache :
[root@localhost ~]# yum clean all
0 文件已删除
[root@localhost ~]# yum makecache
CentOS-8-stream - Base - mirrors.aliyun.com 125 kB/s | 26 MB 03:31
CentOS-8-stream - Extras - mirrors.aliyun.com 39 kB/s | 18 kB 00:00
CentOS-8-stream - AppStream - mirrors.aliyun.com 76 kB/s | 26 MB 05:49
上次元数据过期检查:0:00:01 前,执行于 2022年11月27日 星期日 20时33分17秒。
元数据缓存已建立。
Then update the yum
source .
[root@localhost yum.repos.d]# yum update --allowerasing
There may be many software packages, and it is normal that the update time will be longer.
After the update is complete, it can be used normally. yum
Download the software, yum
and the source configuration file has been updated here.