目录

centos8更换阿里云yum源

目录

centos8更换阿里云yum源

1.centos8更换为阿里云yum源

https://i-blog.csdnimg.cn/direct/2462de495fb44b4b9b269b0204b2d8e3.png

2.更换阿里云Yum-centos8源

mv /etc/yum.repos.d/CentOS-Stream-BaseOS.repo /etc/yum.repos.d/CentOS-Stream-BaseOS.repo.backup


curl -o /etc/yum.repos.d/CentOS-Stream-BaseOS.repo https://mirrors.aliyun.com/repo/Centos-8.repo

wget -O /etc/yum.repos.d/CentOS-Stream-BaseOS.repo https://mirrors.aliyun.com/repo/Centos-8.repo
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# ls
CentOS-Stream-AppStream.repo      CentOS-Stream-Extras.repo            CentOS-Stream-RealTime.repo          epel.repo
CentOS-Stream-BaseOS.repo         CentOS-Stream-HighAvailability.repo  CentOS-Stream-ResilientStorage.repo  epel-testing-modular.repo
CentOS-Stream-BaseOS.repo.backup  CentOS-Stream-Media.repo             CentOS-Stream-Sources.repo           epel-testing.repo
CentOS-Stream-Debuginfo.repo      CentOS-Stream-NFV.repo               epel-modular.repo
CentOS-Stream-Extras-common.repo  CentOS-Stream-PowerTools.repo        epel-playground.repo

3.查询repository列表

https://i-blog.csdnimg.cn/direct/7bc157bcead74a54ab2fab1c4ea5599e.png

4.如果配置后仍然报错 如下

https://i-blog.csdnimg.cn/direct/da41ac1f4de5435487a76078947623e3.png

CentOS Stream 8 - Extras common packages                                                                                        0.0  B/s |   0  B     00:00

Errors during downloading metadata for repository ’extras-common':

  • Curl error (6): Couldn’t resolve host name for [Could not resolve host: mirrorlist.centos.org]

错误:Failed to download metadata for repo ’extras-common’: Cannot prepare internal mirrorlist: Curl error (6): Couldn’t resolve host name for [Could not resolve host: mirrorlist.centos.org]

[root@localhost ~]#

5.解决方案之

干净利索方案

5.1 备份原有yum仓库整个备份

cp -r /etc/yum.repos.d /home/yum.repos.d.bakcup

https://i-blog.csdnimg.cn/direct/f51867a779474131ba55a785bdc930ea.png

5.2.进入原有yum源删除里面所有*.repos文件

cd /etc/yum.repos.d

rm -f *.repo

5.3. 直接覆盖下载阿里云centos-8.0 yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

5.4. 更新yum缓存

yum clean all

yum makecache

OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK