当前位置: 首页 > news >正文

Centos7 使用 yum 报错 Could not retrieve mirrorlist

使用yum的时候报这个错误

在这里插入图片描述

解决方法

进文件夹 备份文件 改文件
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
彻底清理系统中的缓存和临时文件
sudo yum clean all
命令用于创建 yum 缓存,之后等待加载:
sudo yum makecache

在这里插入图片描述

更改为阿里云镜像源执行如下命令
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
彻底清理系统中的缓存和临时文件
sudo yum clean all
命令用于创建 yum 缓存
sudo yum makecache

相关文章:

  • Nmap:网络扫描与安全评估的多功能工具
  • leetcode4:寻找两个正序数组的中位数
  • 双非一本电子信息专业自学嵌入式,学完 Linux 后咋走?单片机 FreeRTOS 要补吗?
  • Elasticsearch7.6.2 安装过程
  • 论文笔记:How Much Can Time-related Features Enhance Time Series Forecasting?
  • python-leetcode 35.二叉树的中序遍历
  • 代码随想录算法训练营Day51
  • 【Go语言快速上手】第二部分:Go语言进阶之并发编程
  • 新手向:SpringBoot后端查询到数据,前端404?(附联调时各传参方式注解总结-带你一文搞定联调参数)
  • golang panic原理
  • 解锁大数据治理:开启数据驱动的新时代
  • 图片粘贴上传实现
  • python统计项目计划中2个日期之间的工作天数
  • ubuntu上/etc/profile.d/目录的作用
  • 保护大数据的最佳实践方案
  • 深入理解TypeScript中的类型守卫
  • C# 中的 lock用法
  • Spring Bean 生命周期的执行流程
  • ES12 weakRefs的用法和使用场景
  • frameworks 之 Activity添加View
  • 17家A股城商行一季报扫描:青岛银行营收增速领跑,杭州银行净利增速领跑
  • 沈晓萍︱严金清:比斯坦因更早获得敦煌文物的无锡名士
  • 邮储银行一季度净赚超252亿降逾2%,营收微降
  • 中使馆:奉劝菲方有关人士不要在台湾问题上挑衅,玩火者必自焚
  • 建发股份:将于5月6日召开股东大会,审议提名林茂等为公司新一届董事等议案
  • 商务部:一季度我国服务贸易较快增长,进出口总额同比增8.7%