CentOS8 yum install 报错Cannot prepare internal mirrorlist: No URLs in mirrorlist解决(替换yum源)
yum install openssl失败了,加 --releasever=8参数也失败了
打开/etc/
打开看下
先备份下
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
清空一下yum缓存
yum clean all
然后重建yum缓存
yum makecache
可以看到,又失败了
我们在替换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
可以看到,源数据缓存已经建立
接下来继续执行yum install即可
可以看到,已经执行成功了
也可以将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
再不行就是网络受限了,加代理或者解决网络问题
学习时的痛苦是暂时的 未学到的痛苦是终生的
作者:卷心菜的奇妙历险
本文版权归作者和博客园共有,遵循 CC 4.0 BY-SA 版权协议,欢迎转载 转载请附上原文出处链接和本声明,否则保留追究法律责任的权利。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话