linux centos7 yum命令失效

linux centos7 yum命令失效

Centos7使用yum命令失效,报错: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; 未知的错误"

我是如何解决的呢,

/etc/yum.repos.d/CentOS-Base.repo 把该文件做了一个备份,然后修改这个文件的内容

首先清空这个文件的内容,其次输入替换内容,我用的是阿里云的镜像:

sudo vi /etc/yum.repos.d/CentOS-Base.repo

复制代码
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

清理并重建缓存

复制代码
sudo yum clean all
sudo yum makecache
sudo yum update
相关推荐
未来之窗软件服务3 小时前
服务器运维(六)跨域配置 Preflight 问题——东方仙化神期
运维·服务器·服务器运维·仙盟创梦ide·东方仙盟
埃伊蟹黄面3 小时前
计算机的“身体”与“灵魂”:冯·诺依曼架构与操作系统
linux
AORO20254 小时前
智能三防手机哪款好?22000mAh+夜视+露营灯打造专业户外装备
服务器·网络·智能手机·电脑·1024程序员节
winner88815 小时前
Linux 软件安装 “命令密码本”:yum/apt/brew 一网打尽
linux·运维·服务器
九河云5 小时前
软件开发平台 DevCloud
运维·服务器·数据库·科技·华为云
firstacui6 小时前
DNS高速缓存&分离解析
服务器
思麟呀6 小时前
Linux的基础IO流
linux·运维·服务器·开发语言·c++
winner88817 小时前
嵌入式Linux驱动开发全流程:工具协作+核心概念拆解(从入门到理解)
linux·运维·驱动开发
ShiinaKaze7 小时前
fatal error: bits/c++config.h: No such file or directory
linux·gcc·g++
TTBIGDATA8 小时前
【Ambari开启Kerberos】KERBEROS SERVICE CHECK 报错
大数据·运维·hadoop·ambari·cdh·bigtop·ttbigdata