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

centos7执行yum命令时报:Could not resolve host: mirrorlist.centos.org; Unknown error

项目场景:

打算学习一下docker,所以重新装了一台虚拟机,centos7。安装完成后,通过 yum 命令下载必要软件时报了错误,对此错误进行了分析,解决和记录。


问题描述

通过yum 命令下载软件的时候报错,如下:

Loaded plugins: 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; Unknown error"One of the configured repositories failed (Unknown),and yum doesn't have enough cached data to continue. At this point the onlysafe 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 workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-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 muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=trueCannot find a valid baseurl for repo: base/7/x86_64

原因分析:

下载软件导致,第一想法是网络是否通的,使用命令ping 了百度

ping www.baidu.com

返回消息正常,说明网络没有问题。
然后通过查找问题,发现是镜像源的问题,可以通过切换镜像源解决。


解决方案:

切换阿里云镜像源。

1.备份之前镜像源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2.下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

centos7

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

或者

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

3.运行命令生成缓存

yum makecache

http://www.mrgr.cn/news/47678.html

相关文章:

  • Docker Desktop 构建java8基础镜像jdk安装配置失效解决
  • 移动云自研云原生数据库入围国采!
  • 玩转 JMeter:Random Order Controller让测试“乱”出花样
  • 网站自动签到
  • Java 模板变量替换——字符串替换器(思路Mybatis的GenericTokenParser)
  • C#语言的字符串处理
  • 网友反馈:移动套餐只能升不能降怎么办?
  • Java多线程面试题
  • 融入、成长与创造 - 数字经济浪潮下的个人转型
  • 论文阅读笔记-Incorporating Copying Mechanism in Sequence-to-Sequence Learning
  • QFontComboBox Class
  • Redis 数据类型list(列表)
  • 系统架构设计师教程 第16章 16.2 嵌入式系统软件架构原理与特征 笔记
  • 十、索引优化与查询优化
  • 解决 IntelliJ IDEA 运行时 “Command line is too long“ 问题
  • 地级市-专利申请与获得情况(1990-2022年)
  • 2024年编程资料【9月份部分】
  • Keil生成lst文件,creating preprocessor file
  • 【分布式技术】简单聊聊什么是区块链
  • 【拥抱AIGC】应该如何衡量AI辅助编程带来的收益
  • 大数据开发基础实训室设备
  • Java项目实战II基于Java+Spring Boot+MySQL的中药实验管理系统(源码+数据库+文档)
  • Spring MVC:精通JSON数据返回的几种高效方式
  • 数据库数据加密的实际作用
  • ElasticsearchClient入门指南
  • 如何使用子查询(Subquery)?