Centos 8 在使用yum命令时提示错误
“为 repo 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs in mirrorlist”
如下图
解决方案如下:
进入/etc/yum.repos.d/目录下,修改CentOS-Linux-AppStream.repo、CentOS-Linux-BaseOS.repo、CentOS-Linux-Extras.repo
注释mirrorlist,取消注释并编辑baseurl文件
编辑CentOS-Linux-AppStream.repo 文件
[appstream]
name=CentOS Linux $releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
baseurl=http://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
编辑CentOS-Linux-BaseOS.repo 文件
[baseos]
name=CentOS Linux $releasever - BaseOS
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
baseurl=http://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
编辑CentOS-Linux-Extras.repo 文件
[extras]
name=CentOS Linux $releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/extras/$basearch/os/
baseurl=http://mirrors.aliyun.com/centos/8-stream/extras/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
修改完文件,清除缓存,重新生成元数据文件
#清除缓存文件
yum clean all
#生成元数据缓存
yum makecache
创建元数据缓存后,重新使用yum命令安装