安装好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的错误

安装好CentOS后,使用yum安装报错_加载

第一种:更改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


愿路途漫长,以后莫失莫忘。 愿你不骄不躁,安稳顺心。


归档:我的知识栈:目录(更新中...)


作者:菜鸟-传奇