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 ...
随机推荐
- npm install及其目录结构
npm install 安装包及其依赖.npm install: 默认情况下,安装package.json文件中列出的所有依赖.加-P或--production后,只安装dependencies列出的 ...
- Yaml配置文件语法详解
YAML 简介 YAML,即 "YAML Ain't a Markup Language"(YAML 不是一种标记语言)的递归缩写,YAML 意思其实是" Yet Ano ...
- [oeasy]python0141_自制模块_module_reusability_复用性
自制包内容 回忆上次内容 上次导入了外部的py文件 import my_module 导入一个自己定义的模块 可以使用my_module中的变量 不能 直接使用 my_module.py文件中的变 ...
- oeasy教您玩转vim - 51 - # 读写文件
读写文件 回忆上节课内容 命令行的光标控制 方向键️️️️️可以控制左右移动 shift+️️️️️按照word左右移动光标 ctrl+b 到开头begin ctrl+e 到结尾end ctrl+w ...
- 【JavaScript高级02】JavaScript第一大神兽:原型和原型链
1,函数中的prototype属性 每个函数都会有一个属性prototy,该属性默认指向一个空Object对象,而这个空的Object对象被称之为原型对象. <script > conso ...
- 配置Sprig security后Post请求无法使用
在学习过程中发现在配置完Spring security后,Post请求失效,无法增删改数据,这里可以通过在Spring Security 的Config类中增加 也可以自定义csrf,不过目前还不是很 ...
- ABC349
A link 其实,有人赢比赛,就有人输比赛,一加一减,不管进行多少场比赛,最后所有人的分数和一定是\(0\). 那么知道\(n-1\)个人的分数和,就可以知道第\(n\)个人的了. 点击查看代码 # ...
- nacos一个奇怪的问题:找不到正确的应用名-环境.后缀名配置文件
spring: profiles: active: dev application: name: system-api cloud: nacos: server-addr: 192.168.101.6 ...
- DNS在架构中的使用
1 介绍 DNS(Domain Name System,域名系统)是一种服务,它是域名和IP地址相互映射的一个分布式数据库,能够使人更方便的访问互联网,而不用去记住能够被机器直接读取的IP地址数串. ...
- vue页面加载慢,chunk-vendors.js文件太大
今天拉取合并了同事的代码后页面加载速度变得非常慢,经过排查发现是因为加载的chunk-vendors.js太大 58m 28s就很离谱 经过同事指导加上百度终于找到解决办法,配置compression ...