CentOS8使用阿里源

详解CentOS8更换yum源后出现同步仓库缓存失败的问题

https://www.jb51.net/article/183693.htm

 

 

问题起因:一开始CentOS 8默认的yum源是能够正常使用的,但使用如下命令安装了Development Tools之后:

1
yum groupinstall -y "Development Tools"

不知道为啥就开始出现同步仓库缓存失败的问题,无法正常安装一些工具包。错误提示如下:

1
2
3
4
5
6
7
8
9
[root@localhost /etc/yum.repos.d]# yum makecache
CentOS-8.0 - AppStream                  19 B/s | 38 B   00:02 
CentOS-8.0 - Base                     24 B/s | 38 B   00:01 
CentOS-8.0 - Extras                    8.4 B/s | 38 B   00:04 
同步仓库 'AppStream' 缓存失败,忽略这个 repo。
同步仓库 'BaseOS' 缓存失败,忽略这个 repo。
同步仓库 'extras' 缓存失败,忽略这个 repo。
元数据缓存已建立。
[root@localhost /etc/yum.repos.d]#

于是根据错误提示信息到网上查找相关解决方案,大部分都是说更换阿里的yum源,然后就按官方文档的说明进行了更换:

https://developer.aliyun.com/mirror/centos

本来以为已经顺利解决了,想不到还有坑,重新建立元数据缓存时依旧提示同步仓库缓存失败:

1
2
3
4
5
6
7
8
9
10
11
12
[root@mesos-master /etc/yum.repos.d]# yum makecache
CentOS-8.0 - AppStream - mirrors.aliyun.com          0.0 B/s |  0 B   00:24 
CentOS-8.0 - Base - mirrors.aliyun.com            0.0 B/s |  0 B   00:32 
CentOS-8.0 - Extras - mirrors.aliyun.com           0.0 B/s |  0 B   00:32 
CentOS-8.0 - Epel                       2.3 MB/s | 6.0 MB   00:02 
WANdisco SVN Repo 1.9                     2.0 kB/s | 121 kB   01:01 
同步仓库 'AppStream' 缓存失败,忽略这个 repo。
同步仓库 'base' 缓存失败,忽略这个 repo。
同步仓库 'extras' 缓存失败,忽略这个 repo。
上次元数据过期检查:0:00:01 前,执行于 2020年03月23日 星期一 10时26分48秒。
元数据缓存已建立。
[root@mesos-master /etc/yum.repos.d]#

然后百思不得其解,我寻思系统默认的yum源可能因为网络的原因连不上也就算了,国内的源不应该啊,是不是配置有问题呢?结果还真是,baseurl中的$releasever和$basearch占位符不知为何无效。故将$releasever改为8,将$basearch改为x86_64后问题解决。修改后的各个配置文件内容如下:

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
54
55
56
57
58
### cat CentOS-Base.repo ###
[base]
name=CentOS-8 - Base - mirrors.aliyun.com
failovermethod=priority
gpgcheck=1
 
### cat CentOS-AppStream.repo ###
[AppStream]
name=CentOS-8 - AppStream - mirrors.aliyun.com
failovermethod=priority
gpgcheck=1
 
### cat CentOS-Extras.repo ###
[extras]
name=CentOS-8 - Extras - mirrors.aliyun.com
failovermethod=priority
gpgcheck=1
 
### cat CentOS-Epel.repo ###
[epel]
name=CentOS-$releasever - Epel
enabled=1
gpgcheck=0
 
### cat CentOS-PowerTools.repo ###
[PowerTools]
name=CentOS-8 - PowerTools - mirrors.aliyun.com
failovermethod=priority
gpgcheck=1
enabled=0
 
### cat CentOS-centosplus.repo ###
[centosplus]
name=CentOS-8 - Plus - mirrors.aliyun.com
failovermethod=priority
gpgcheck=1
enabled=0

做完以上修改后问题解决,没有再提示同步仓库缓存失败了:

1
2
3
4
5
6
7
8
[root@localhost /etc/yum.repos.d]# yum makecache
CentOS-8 - AppStream - mirrors.aliyun.com           2.1 MB/s | 6.5 MB   00:03 
CentOS-8 - Base - mirrors.aliyun.com              1.6 MB/s | 5.0 MB   00:03 
CentOS-8 - Extras - mirrors.aliyun.com             1.8 kB/s | 4.2 kB   00:02 
CentOS-8.0 - Epel                       2.2 MB/s | 6.0 MB   00:02 
WANdisco SVN Repo 1.9                     10 kB/s | 121 kB   00:11 
元数据缓存已建立。
[root@localhost /etc/yum.repos.d]#

到此这篇关于详解CentOS8更换yum源后出现同步仓库缓存失败的问题的文章就介绍到这了,更多相关CentOS8更换yum源同步仓库失败内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

---------------------------------------------------------------------------------------------------------

错误:同步仓库 'mongodb-org-4.0' 缓存失败

vim /etc/yum.repos.d/mongodb-org-4.2.repo

[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

yum install -y mongodb-org

 

---------------------------------------------------------------------------------------------

查看centos版本号

[root@localhost tensorflow]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)

 

修改AppStream对应的配置文件
用编辑器打开/etc/yum.repos.d/CentOS-AppStream.repo

vim /etc/yum.repos.d/CentOS-AppStream.repo

注释掉mirrorlist所在行,消除对baseurl的注释,并将baseurl后面的地址改为阿里云中对应的AppStream库地址

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/8.0.1905/AppStream/x86_64/os/

保存退出

 

修改BaseOS库
打开文件

vim /etc/yum.repos.d/CentOS-Base.repo 

注释掉mirrorlist行,修改baseurl行

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/8.0.1905/BaseOS/x86_64/os/

保存退出

 

修改Extra库
打开文件

vim /etc/yum.repos.d/CentOS-Extras.repo

修改

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/8.0.1905/extras/x86_64/os/

保存退出


测试运行

[root@localhost tensorflow]# yum update
CentOS-8 - AppStream                                                                                3.4 kB/s | 4.3 kB     00:01
CentOS-8 - Base                                                                                     2.1 MB/s | 7.9 MB     00:03
CentOS-8 - Extras                                                                                   773  B/s | 2.1 kB     00:02
依赖关系解决。
无需任何处理。
完毕!

 

posted on 2019-12-16 16:14  trp  阅读(14558)  评论(0编辑  收藏  举报

导航