侧边栏

安装好CentOS后,使用yum安装报错

安装好CentOS后,使用yum安装报错

安装好CenOS7后,自带的yum不能直接使用,使用会出现如下问题:t

已加载插件:fastestmirror, langpacks File contains no section headers. 

已加载插件:fastestmirror, langpacks
http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below wiki article

报出404的错误

第一种:更改yum源

原因是没有配置yum源,修改/etc/yum.repos.d/CenOS-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/ 
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/ 
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/ 
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/ 
gpgcheck=1 
enabled=0 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 
复制代码

第二种:删除原有yum文件

如果不行,这样,删除原有的文件:

rm -f /etc/yum.repos.d/CentOS-Base.repo 

然后重新下载阿里的:

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

 清理缓存:

yum clean all

第三种:删除所有yum文件

ps:如果上述方法没有解决,尝试下面:

删除yum.repos.d目录下所有文件

rm -f /etc/yum.repos.d/* 

 然后重新下载阿里的:

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

清理缓存:

yum clean all

测试下载安装:

yum install gcc 
posted @   菜鸟-传奇  阅读(2446)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示