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

安装好CentOS后,使用yum安装报错 转载
mob604756f976e62021-03-09 19:09:00
文章标签Linuxcentosyum源加载清理缓存文章分类其它其它阅读数141

安装好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
1.
2.
3.
4.
5.
6.

报出404的错误

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

第一种:更改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- r e l e a s e v e r − B a s e m i r r o r l i s t = h t t p : / / m i r r o r l i s t . c e n t o s . o r g / ? r e l e a s e = releasever - Base mirrorlist=http://mirrorlist.centos.org/?release= releaseverBasemirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=os&infra=infra
#baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / o s / releasever/os/ releasever/os/basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS- r e l e a s e v e r − U p d a t e s m i r r o r l i s t = h t t p : / / m i r r o r l i s t . c e n t o s . o r g / ? r e l e a s e = releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release= releaseverUpdatesmirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=updates&in…infra
#baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / u p d a t e s / releasever/updates/ 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- r e l e a s e v e r − E x t r a s m i r r o r l i s t = h t t p : / / m i r r o r l i s t . c e n t o s . o r g / ? r e l e a s e = releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release= releaseverExtrasmirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=extras&inf…infra
#baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / e x t r a s / releasever/extras/ 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- r e l e a s e v e r − P l u s m i r r o r l i s t = h t t p : / / m i r r o r l i s t . c e n t o s . o r g / ? r e l e a s e = releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release= releaseverPlusmirrorlist=http://mirrorlist.centos.org/?release=releasever&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=centosplus…infra
#baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / c e n t o s p l u s / releasever/centosplus/ releasever/centosplus/basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.

第二种:删除原有yum文件
如果不行,这样,删除原有的文件:

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

然后重新下载阿里的:

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

清理缓存:

yum clean all
1.

第三种:删除所有yum文件
ps:如果上述方法没有解决,尝试下面:

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

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

然后重新下载阿里的:

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

清理缓存:

yum clean all
1.

测试下载安装:

yum install gcc
1.

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

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

作者:菜鸟-传奇

CentOS 7上使用yum下载时出现错误可能有多种原因。以下是一些常见的解决方案: 1. **网络问题**:确保你的网络连接正常,并且能够访问yum仓库。你可以尝试ping命令来检查网络连接,例如:`ping yum.centos.org`。 2. **yum配置问题**:检查yum的配置文件`/etc/yum.repos.d/`,确保所有的仓库配置文件都是正确的。如果存在任何错误或缺失的仓库配置文件,可以使用以下命令进行修复和添加: ```bash for file in /etc/yum.repos.d/*.repo; do sed -i 's/\[base]//' "$file"; done ``` 这将删除所有配置文件中的`[base]`部分,确保所有仓库都被正确识别。 3. **更新yum**:确保你的yum是最新的版本。可以使用以下命令更新yum: ```bash sudo yum update yum ``` 4. **清理缓存**:有时候缓存问题可能导致下载错误。可以使用以下命令清理yum缓存: ```bash sudo yum clean all ``` 然后再尝试重新下载。 5. **使用不同的仓库**:如果你的默认仓库出现问题,可以尝试使用其他仓库进行下载。找到可用的仓库链接并替换默认的`CentOS-Base.repo`文件中的相应条目。 6. **查看详细错误信息**:在出现错误时,查看详细的错误信息可以帮助你了解问题的根本原因。可以使用以下命令查看yum的错误日志: ```bash sudo yum install -d 5 'yum-utils' && sudo yum repquirerepair ``` 这将显示有关错误的详细信息,并尝试修复任何配置问题。 7. **检查防火墙设置**:确保防火墙允许yum访问所需的网络端口。如果防火墙阻止了必要的连接,可能会影响yum的下载过程。 8. **重新安装yum**:如果上述方法都无法解决问题,可以尝试重新安装yum。这将清除任何可能存在的损坏或冲突的组件。可以使用以下命令进行重新安装: ```bash sudo yum remove yum-utils sudo yum install yum-utils ``` 请根据你的具体情况尝试上述解决方案,并逐个尝试以确定导致问题的具体原因。如果问题仍然存在,请提供更多详细的错误信息,以便我能够更好地帮助你解决问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值