CentOS-8.4系统配置国内清华镜像站yum源

一、为啥要更改yum源

1、Centos 8官方已于2021年12月31日以后停止Centos 8支持、转至Centos 8 Stream项目支持2021年12月31日以后,CentOS Linux 8的使用者将无法获得包括问题修复和功能更新在内的任何软件维护和支持。

2、Centos Stream 是一个面向开发者的滚动发布的 Linux 发行版,CentOS Streams 可以当成是用来体验最新红帽系 Linux 特性的一个版本。

3、因此,你追求稳定性,或者个人日常使用,都更推荐使用传统的 CentOS Linux 这个版本。

4、官方渠道已经停止了CentOS8的下载,只有CentOS8-stream,我们可以去清华大学开源软件镜像站下载centos-vault版本

https://mirrors.tuna.tsinghua.edu.cn/centos-vault/

 

 

 

 二、系统安装完成后,准备修改yum源

1、确保网络可以连接外网

ping -c 4 baidu.com

 2、更改yum源为清华源

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 8.4.2105
[root@localhost ~]# 
[root@localhost ~]# minorver=8.4.2105
[root@localhost ~]# 
[root@localhost ~]# sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" -e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$minorver|g" -i.bak /etc/yum.repos.d/CentOS-*.repo
[root@localhost ~]# 

查看系统版本号 8.4.2105

minorver=8.4.2105 将系统版本号作为下条命令的变量值

修改yum源地址

sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" -e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$minorver|g" -i.bak /etc/yum.repos.d/CentOS-*.repo
3、测试yum源是否可用

[root@localhost ~]# yum clean all
18 文件已删除
[root@localhost ~]# yum makecache 
CentOS Linux 8 - AppStream                                                                                                                     6.0 MB/s | 9.6 MB     00:01    
CentOS Linux 8 - BaseOS                                                                                                                        7.2 MB/s | 8.5 MB     00:01    
CentOS Linux 8 - Extras                                                                                                                         23 kB/s |  10 kB     00:00    
元数据缓存已建立。
[root@localhost ~]# 
[root@localhost ~]# yum repolist 
仓库 id                                                                        仓库名称
appstream                                                                      CentOS Linux 8 - AppStream
baseos                                                                         CentOS Linux 8 - BaseOS
extras                                                                         CentOS Linux 8 - Extras
[root@localhost ~]# 

元数据缓存已建立。证明yum源配置正确,显示的仓库id表示yum源可正常使用

猜你喜欢

转载自blog.csdn.net/wxqndm/article/details/130348104