centos中yum安装时提示Cannot find a valid baseurl for repo: base/7/x86_64 出现仓库源问题

引言

centos中yum安装时报Cannot find a valid baseurl for repo: base/7/x86_64

错误如下

复制代码
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"


 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

解决

备份源仓库

复制代码
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak

拉取新源

复制代码
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

刷新缓存

复制代码
yum clean all
yum makecache

安装测试

复制代码
yum -y install vim
相关推荐
顶点多余3 分钟前
9.15 面试问题总结(一面挂)
linux·面试·职场和发展
秦jh_6 分钟前
【Docker】容器
运维·docker·容器
顺风尿一寸11 分钟前
从 ls -U 到 Tomcat libs加载jar包:ext4 目录哈希序如何影响 Java 文件排序顺序
linux·jvm
刘婉晴21 分钟前
【K8S】配置和连接介绍
运维
网硕互联的小客服29 分钟前
如何在Ubuntu系统上查看和刷新DNS缓存?操作方法与原理解析
运维·服务器·网络·ubuntu
码农学院33 分钟前
制造业B2B官网GEO实战:用 Python 向量相似度给老产品手册自动补语义内链,让 AI 爬虫抓得更深
运维·人工智能·爬虫·ai优化aio
qeen8740 分钟前
【Linux】操作系统之进程介绍(一)
linux·笔记·学习·进程
亚川楼宇自控系统数据中心厂家42 分钟前
从电表到碳报告:能碳管理系统如何支撑机房双碳合规
运维
邪修king44 分钟前
Re:Linux系统篇(二十五):文件系统(一):磁盘硬件底层原理:从物理结构到 CHS/LBA 寻址,搞懂硬盘数据的定位逻辑
java·linux·运维·gpt
小则又沐风a1 小时前
TCP协议讲解-----了解TCP可靠性的基石
linux