CentOS 7 yum无法使用解决方法Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=
在centos7中使用yum命令时候报错:
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; 未知的错误"

问题原因
出现这个错误是因为使用的 CentOS 7 仓库已经被归档,当前的镜像地址无法找到所需的文件。CentOS 7 的官方支持已经结束,部分仓库已被移至归档库。这导致了你的 yum 命令无法找到所需的元数据文件。CentOS 7 的官方仓库在 2024 年 6 月 30 日之后已经停止维护。因此,使用最新的 CentOS 7 官方仓库可能会遇到问题。
解决方法
进入/etc/yum.repos.d目录下找到 CentOS-Base.repo
进入目录:
cd /etc/yum.repos.d

之后依次执行:
cp CentOS-Base.repo CentOS-Base.repo.backup
vi CentOS-Base.repo
进入后改为:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# 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, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#$baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
然后wq保存下,依次执行:
sudo yum clean all
sudo yum makecache
之后等待加载:

阿里云镜像源
以下两个命令都可以,执行完成后进入/etc/yum.repos.d
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
然后执行:
cat CentOS-Base.repo

看着镜像是阿里云的即可。 建议在执行下
sudo yum clean all
sudo yum makecache
欢迎关注公众号:愚生浅末
CentOS 7 yum无法使用解决方法Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=的更多相关文章
- VMware虚拟机的CentOS无法上网的解决方法
前言:由于Linux下很多软件安装必须网络环境下进行,因此,对于如何在VMware下进行上网,我折腾了至少三天,今天上午,也即五一劳动节,终于搜到一遍技术文章,经过自己实践,VMware下Linux的 ...
- 树莓派(Raspberry Pi 3)安装centos7后yum无法使用解决办法
树莓派(Raspberry Pi 3)安装centos7后yum无法使用解决办法 人穷,闲鱼淘了个二手的树莓派3 英国版,无奈咱也不会用,很无奈~ 安装教程百度到的差不多都可以,找个格式正常的一步一步 ...
- 001. 使用ssh连接不上centos 6.5的解决方法及其解决中文乱码
1. 使用ssh连接不上centos 6.5的解决方法: 错误显示: Connecting to 192.168.1.106:22... Could not connect to '192.168.1 ...
- CentOS 大量的TIME_WAIT解决方法
CentOS 大量的TIME_WAIT解决方法 最近个人博客总是出现无法打开的现象,具体表现为,打开页面需要等待n长时间,登陆系统后发现系统存在大量TIME_WAIT状态的连接,google了一下解决 ...
- VMware workstation虚拟机配置文件不兼容无法使用解决方法
VMware workstation虚拟机配置文件不兼容无法使用解决方法打开VMware workstation虚拟机提示:配置文件"--.vmx"是由Vmware产品创建,但该产 ...
- centos在yum install报错:Another app is currently holding the yum lock解决方法
centos在yum install报错:Another app is currently holding the yum lock,这个问题可能是很多的新手经常遇到问题,之前也有人问我,包括本人在刚 ...
- yum出现“No module named yum”错误解决方法
安装了一个Python2.7,隔天发现yum无法使用,报错信息如下,应该是系统是使用的默认的python2.6的版本 解决办法修改yum文件#vi /usr/bin/yum将 #!/usr/bin/p ...
- centos 更换yum源 (解决下载慢的问题)
先看有没有安装wget wget -V 如果没有执行 yum -y install wget 进行安装 然后进行配置的备份 mv /etc/yum.repos.d/CentO ...
- Another app is currently holding the yum lock解决方法
用yum安装包有时候会提示 ``` Another app is currently holding the yum lock; waiting for it to exit... The oth ...
- mac os ssh远程链接centos提示证书错误解决方法
下面是错误提示 IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you ...
随机推荐
- 【ClickHouse】0:clickhouse学习4之表相关操作
Clickhouse对表操作分为四大类:增删查改(INSERT,DROP,SELECT,ALTER). 增,删,查比较简单,改最复杂.那具体有哪些改的操作呢?如下清单: ALTER ALTER TAB ...
- MFC基于对画框工程笔记->更改窗口图标以及生成的.exe图标
一.前言 继前一篇生成MFC基于对话框工程->新建MFC对话框后,开始改动对话框图标以及生成的.exe图标. 原对话框图标以及.exe图标: 在菜单栏中选择生成目录为Release 打开Rele ...
- vue-router 路由模式有几种?
实际上存在三种模式: Hash: 使用URL的hash值来作为路由.支持所有浏览器. History: 以来HTML5 History API 和服务器配置.参考官网中HTML5 His ...
- django redirect_authenticated_user
redirect_authenticated_user是在Web开发框架(如Django)中常见的设置,用于控制身份验证重定向的行为. 当启用redirect_authenticated_user时, ...
- Java实现快速快速排序算法
算法简介 快速排序(Quick Sort) 是由冒泡排序改进而得的.在冒泡排序过程中,只对相邻的两个记录进行比较,因此每次交换两个相邻记录时只能消除一个逆序.如果能通过两个(不相邻)记录的一次交换直接 ...
- [oeasy]python0048_注释_comment_设置默认编码格式
注释Comment 回忆上次内容 使用了版本控制 git 制作备份 进行回滚 尝试了 嵌套的控制结构 层层 控制 不过 除非 到不得以 尽量不要 太多层次的嵌套 这样 从顶到底 含义 明确 ...
- [oeasy]python0110 屏幕点阵字体_3x5_5x7_雅达利字库
动视 桥牌 想用 7 x 5 描述黑红梅方 还是比较难的 添加图片注释,不超过 140 字(可选) 而且最下面的动视logo是 修改后的字体 还挺有动感 这个时代 图像库 和 ...
- Volatile不保证原子性及解决方案
原子性的意义 原子性特别是在并发编程领域,是一个极其重要的概念,原子性指的是一个操作或一组操作要么全部执行成功,要么全部不执行,不会出现部分执行的情况.这意味着原子性操作是不可分割的,它们在执行过程中 ...
- JavaScript 常用 Web APIs
Web APIs Web APIs DOM 页面文档对象模型 DOM 树 获取元素 事件 监听事件 事件解绑 操作元素 样式属性操作 结点操作 结点关系 创建节点 DOM 事件流 事件对象 常用鼠标事 ...
- OI-Wiki 学习笔记
算法基础 \(\text{Update: 2024 - 07 - 22}\) 复杂度 定义 衡量一个算法的快慢,一定要考虑数据规模的大小. 一般来说,数据规模越大,算法的用时就越长. 而在算法竞赛中, ...