解决centos8安装后不能使用yum的问题

安装了centos8之后,使用yum命令安装软件时时,系统会提示Error: Failed to download metadata for repo ‘AppStream’ …

原因是CentOS 8将不再从官方CentOS项目获得开发资源。需要更改镜像资源,有两种解决方法如下

第一种方法:

1.创建一个备份目录

mkdir /etc/yum.repos.d/backup

2.将/etc/yum.repos.d下所有的文件转移到刚刚创建的目录

mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup

3.进入/etc/yum.repos.d目录下,开始写我们配置的镜像文件

文件名任意取,但是后缀必须为repo

[root@localhost yum.repos.d]#vim base.repo
[BaseOS]
name=BaseOS
baseurl=https://mirrors.aliyun.com/centos/\$releasever/BaseOS/\$basearch/os/
gpgcheck=0

[AppStream]
name=AppStream
baseurl=https://mirrors.aliyun.com/centos/\$releasever/AppStream/\$basearch/os/
gpgcheck=0

[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/\$releasever/extras/\$basearch/os/
		https://mirror.tuna.tsinghua.edu.cn/centos/\$releasever/extras/\$basearch/os/
		http://mirrors.163.com/centos/\$releasever/extras/\$basearch/os/
		https://mirrors.nju.edu.cn/centos/\$releasever/extras/\$basearch/os/
gpgcheck=0
enabled=1

[epel]
name=EPEL
baseurl=hhttps://mirror.tuna.tsinghua.edu.cn/epel/\$releasever/Everything/\$basearch
        https://mirrors.cloud.tencent.com/epel/\$releasever/Everything/\$basearch
        https://mirrors.huaweicloud.com/epel/\$releasever/Everything/\$basearch
        https://mirrors.aliyun.com/epel/\$releasever/Everything/\$basearch
gpgcheck=0
enabled=1

4.清理缓存

yum clean all

5.构建新的缓存

yum makecache

注意:以上匹配的路径是在阿里巴巴,清华大学等镜像网站中的,在构建缓存时,若系统提示404,则有可能有些镜像网站已经不可用了,可自行排查或更换路径,或者使用第二种方法

第二种方法:

使用阿里云提供的写好的CentOS8仓库文件,下载链接如下

repo安装包下载_开源镜像站-阿里云repo安装包是阿里云官方提供的开源镜像免费下载服务,每天下载量过亿,阿里巴巴开源镜像站为包含repo安装包的几百个操作系统镜像和依赖包镜像进行免费CDN加速,更新频率高、稳定安全。http://mirrors.aliyun.com/repo/

你可能感兴趣的:(centos,linux)