CentOS8 yum install 报错Cannot prepare internal mirrorlist: No URLs in mirrorlist解决(替换yum源)

简介: CentOS8 yum install 报错Cannot prepare internal mirrorlist: No URLs in mirrorlist解决(替换yum源)

1898904-20220210102236866-1827210644.png


 yum install openssl失败了,加 --releasever=8参数也失败了


打开/etc/

1898904-20220210102348135-275438611.png

1898904-20220210102415228-1861632652.png

打开看下

1898904-20220210102445136-128806643.png

先备份下

mv ./CentOS-Linux-BaseOS.repo ./CentOS-Linux-BaseOS.repo.bak

然后执行

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos8_base.repo

1898904-20220210102637731-933283626.png

清空一下yum缓存

 yum clean all

1898904-20220210102726381-332821688.png

然后重建yum缓存

yum makecache

1898904-20220210102758033-1612844819.png

可以看到,又失败了


我们在替换yum源的时候,按照镜像网站的操作方式,只替换了CentOS-Base.repo。


可是在CentOS8中,CentOS-Linux-AppStream.repo的内容没有更新


最好先备份下,我这边直接修改了

vi ./CentOS-Linux-AppStream.repo 
# CentOS-Linux-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client.  You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the mirrorlist does not work for you, you can try the commented out
# baseurl line instead.
#[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/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[appstream]
name=Qcloud centos AppStream - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official
~                                                                                                                                                                                                                              
~

将原来的[appstream]注释掉,然后修改,wq保存


然后再执行重建yum缓存


yum makecache

1898904-20220210103241397-519235194.png

可以看到,源数据缓存已经建立


接下来继续执行yum install即可

1898904-20220210103417993-429172727.png

1898904-20220210103438839-539245775.png

可以看到,已经执行成功了


也可以将CentOS-Linux-AppStream.repo删除,不推荐,注意有的版本叫CentOS-Base.repo和CentOS-AppStream.repo


还有[appstream]有的版本是大写[AppStream]


另附两个源地址


阿里yum源: https://developer.aliyun.com/mirror/centos


腾迅yum源: https://mirrors.tencent.com/help/centos.html


至此问题解决


如果还不行可以查看下网卡配置里的DNS可以先配置为8.8.8.8试一下,或者修改/etc/resolv.conf里的nameserver为8.8.8.8


再不行就是网络受限了,加代理或者解决网络问题

 

相关文章
|
1月前
|
关系型数据库 MySQL Linux
在CentOS上使用yum安装与使用MySQL
在CentOS操作系统上使用yum包管理器安装和配置MySQL数据库的详细步骤,包括下载MySQL的yum源配置、安装MySQL服务、启动和停止服务、设置开机自启动、获取临时密码、修改root用户密码、授权用户以及处理相关问题。同时,文章还包含了一些操作的截图,帮助用户更直观地理解安装和配置过程。
260 0
在CentOS上使用yum安装与使用MySQL
|
19天前
|
Linux
centos使用阿里的yum源
centos使用阿里的yum源
|
1月前
|
网络协议 Linux
CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org;"之解决办法(换源)
CentOS7 yum安装报错“Could not resolve host: mirrorlist.centos.org; Name or service not known“之解决办法(换源)
|
1月前
|
缓存 Linux 网络安全
解决 CentOS 7 官方 yum 仓库无法使用的最佳实践
【8月更文挑战第18天】若 CentOS 7 的官方 YUM 仓库无法使用,可按以下步骤解决: 1. **检查网络连接**: - 确认服务器能正常上网,可通过访问外部网站或网络诊断测试。 - 检查防火墙设置,避免其阻挡 YUM 的网络访问。 2. **检查 YUM 配置**: - 核实 `/etc/yum.repos.d/` 下的 `CentOS-Base.repo` 文件中仓库地址正确无误。 - 确认配置文件内的 `enabled` 选项设为 `1` 以启用仓库。
396 0
|
1月前
|
Linux Docker 容器
在CentOS操作系统上使用yum安装/使用/卸载Docker容器引擎
在CentOS操作系统上安装、配置、使用和卸载Docker容器引擎的详细步骤,包括配置Docker镜像加速的方法。
161 0
|
1月前
|
jenkins Java Devops
CentOS 7上安装 Jenkins 2.346 -- yum 方式
CentOS 7上安装 Jenkins 2.346 -- yum 方式
63 0
|
1月前
|
jenkins Linux 持续交付
CentOS 7上安装 Jenkins 2.227 -- yum 方式
CentOS 7上安装 Jenkins 2.227 -- yum 方式
91 0
|
Linux Perl
Centos8 yum源配置方法
本文介绍了Centos8 版本中yum的配置
7678 30
Centos8 yum源配置方法
|
网络协议 网络虚拟化
CentOS8下yum源配置及nmcli命令简单介绍
CentOS8下yum源配置及nmcli命令简单介绍
1078 0
CentOS8下yum源配置及nmcli命令简单介绍
【CentOS8】 本地yum源配置
centos8系统的本地yum源配置稍稍有些不同
1998 0
【CentOS8】 本地yum源配置