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 ...
随机推荐
- Log4j日志输出级别详解
log4j定义了8个级别的log 日志记录器(Logger)的行为是分等级的: 1.分为OFF(关闭所有日志).FATAL(致命错误).ERROR(异常报错).WARN(潜在错误).INFO.DEBU ...
- [oeasy]python0007-调试程序_debug
调试程序 回忆上次内容 py 的程序是按照顺序执行的 是一行行挨排解释执行的 程序并不是数量越多越好 kpi也在不断演化 编辑 写的代码越多 出现的bug就越多 什么是bug 如何找bu ...
- CF1468N 题解
洛谷链接&CF 链接 题目简述 共有 \(T\) 组数据,对于每组数据: 有三个桶,五种垃圾,每个桶有固定的容量. 前三种垃圾分别放入三种桶中,第四种垃圾可以放进 \(1,3\) 桶中,第五种 ...
- 第五节 JMeter基础-初级登录【断言的好处】
声明:本文所记录的仅本次操作学习到的知识点,其中商城IP错误,请自行更改. 1.认识JMeter (1)断言 预期结果和实际结果的比较,如果不一样,断言失败. 2.注册 (1)直接复制[登录]粘贴一下 ...
- css 蛇形排序
先看效果 需求: 一个[ 4 * ?]的网格布局,奇数行 布局 从左往右,偶数行 布局 从右往左. 思路1: js将数组按4个每份进行分割,将偶数份进行反向,然后再将分割后的数据,重新组装.( 太麻 ...
- scratch少儿编程卡通三国背景72张全套素材包【免费下载】
scratch卡通三国题材背景图片,共72张,让你轻松打造scratch三国世界! 免费下载地址:https://www.xiaohujing.com.cn 这套背景图片以卡通风格呈现,色彩鲜艳.造型 ...
- el-date-picker 时间日期格式,选择范围限制
背景:ElementUI的 el-date-picker 使用时,有时候想要限制用户选择的时间范围,但是用的是datetimerange类型的选择器,不想单独写两个起始的选择器.我发现网上的方案大部分 ...
- Jmeter函数助手19-machineName
machineName函数用于获取当前计算机的用户名. 存储结果的变量名(可选)
- 【H5】16 表单 其五 表单验证
在将数据提交到服务器之前,重要的是确保以正确的格式填写所有必需的表单控件.这称为客户端表单验证,可帮助确保所提交的数据符合各种表单控件中规定的要求.本文将引导您通过基本概念和客户端表单验证示例. 先决 ...
- 【C】Re08 内存
一.概述 程序运行之后,所有的数据加载到内存上 内存会被操作系统进行分区处理, 划分的区域主要分为4个: [1.代码文本区 text] 存放开发者编写的代码文本,二进制内容形式 [2.静态全局区 St ...