起因:
在阿里云上买了个centos服务器,但是yum的时候报错,查了下是连不上微软的源。
报这个错误:Error: Failed to synchronize cache for repo 'BaseOS'
报错如下:
[root@iZbp1j62zviuaiizue37Z yum.repos.d]# yum install -y lrzsz
CentOS-8 - AppStream 103 kB/s | 4.4 kB 00:00
CentOS-8 - Base 56 kB/s | 2.3 kB 00:00
Error: Failed to synchronize cache for repo 'BaseOS'
解决办法,有让换BaseOS的链接的,还有换源文件的。
下面我们采取换文件的方式
1、先删除文件
rm -rf /etc/yum.repos.d/CentOS-Base.repo
2、再下载文件
curl -o /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo
3、清理老的缓存
dnf clean all
4、生成新的缓存
dnf repolist
5、执行完,出现下面的这个就可以了。
[root@iZbp1j62zviuaiizue37Z yum.repos.d]# dnf repolist
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
CentOS-8 - AppStream 6.1 MB/s | 21 MB 00:03
CentOS-8 - Base - repo.huaweicloud.com 2.9 MB/s | 4.6 MB 00:01
CentOS-8 - PowerTools - repo.huaweicloud.com 3.8 MB/s | 2.3 MB 00:00
CentOS-8 - Extras - repo.huaweicloud.com 34 kB/s | 10 kB 00:00
repo id repo name status
AppStream CentOS-8 - AppStream 15,665
BaseOS CentOS-8 - Base - repo.huaweicloud.com 1,896
PowerTools CentOS-8 - PowerTools - repo.huaweicloud.com 1,693
extras CentOS-8 - Extras - repo.huaweicloud.com 38
|