解决Centos7系统更新时报错:Could not resolve host: mirrorlist.centos.org; 未知的错误

admin11个月前IT技术631

1、背景

        centos7系统在执行:sudo yum update,发生错误;


1.1、错误描述

        [root@localhost ~]# sudo yum update

已加载插件:fastestmirror, langpacks 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; 未知的错误"




2、原因分析

        原因是国内网络不能访问外网,所以需要将mirrorlist.centos.org替换为国内可以访问的镜像源。


3、解决问题

3.1、CentOS7 原生 yum 源修改为阿里 yum 源

3.1.1、备份原来的 yum 源

sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.back

3.1.2、下载阿里云的 yum 源文件并替换本地 yum 源文件

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

#清理缓存

sudo yum clean all

#生成新的缓存

 sudo yum makecache

#更新yum

 sudo yum updata

3.1.3、添加 epel 源

3.1.3.1、epel源与yum源说明

        epel源:(Extra Packages for Enterprise Linux) :epel是一个由Fedora项目支持的补充软件仓库,专为RHEL(Red Hat Enterprise Linux)及其衍生版如CentOS设计。它扩展了企业级Linux发行版的软件包库,提供大量不在官方库中的开源软件,增强了系统的功能性与灵活性。

yum源:(Yellowdog Updater, Modified)是Red Hat引入的包管理工具,它通过自动解决依赖关系,简化了软件的安装、更新和卸载过程。YUM源本质上是指向软件包仓库的配置信息,这些仓库包含了与特定Linux发行版(如RHEL/CentOS)兼容的官方软件包,确保了软件包的稳定性和兼容性。


3.1.3.2、查看一下系统是否已有 epel

sudo rpm -qa |grep epel  

3.1.3.3、有则卸载

#如果有的话先用下面的命令卸载以前的 epel 以免受影响


sudo rpm -e epel-release 

3.1.3.4、下载阿里的 epel 源

sudo wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo

3.1.3.5、清洗缓存并生成新的缓存

#清理缓存

sudo yum clean all

#生成新的缓存

sudo yum makecache


                        

原文链接:https://blog.csdn.net/qingzhumuqingfeng/article/details/144469012


相关文章

magento1-2的部分使用经验总结

完成magento 1.x 到2.x的版本测试与服务器速度测试得出结论magento慢的原因软件原因1.javascrip  html css 文件 没有合并与压缩 设置 Merge Jav...

美国人喜欢自己动手装修房子

参考文献::http://www.sohu.com/a/291910017_100085730原因有三:1.美国人工贵       ...

二维码生成导航

http://twoyn.shengmake.nethttp://twalabo.shengmake.nethttp://twyilang.shengmake.nethttp://twyindu.sh...

excel打开csv 出现乱码怎么解决

1使用记事本打开CSV文件2点击菜单:文件-另存为,编码方式选择ANSI3保存完毕后,再用EXCEL打开这个文件就不会出现乱码的情况...

Apache的几种常用配置

Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。     ...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。