Linux系统中使用yum命令报错
问题现象
客户开的一个阿里云的服务器,拿到手后想安装一个docker,但是一输命令,结果凉了。报了各种错误
[root@iZut201mqskxuwsblw52rdZ yum.repos.d]# yum install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
http://yum.tbsite.net/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
One of the configured repositories failed (CentOS-7),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=base ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable base
or
subscription-manager repos --disable=base
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=base.skip_if_unavailable=true
failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
http://yum.tbsite.net/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
问题解决
删除原有的yum安装包文件
1 删除老仓库文件
cd /etc/yum.repos.d
rm *.*
2.卸载yum包
rpm -qa yum yum-3.4.3-150.el7.centos.noarch
3.卸载安装组件
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa yum
根据系统版本,下载安装包
安装包下载传送门
注意,以下的包中间的*号代表的是具体的版本信息,各版本不同的话不一致。
yum-*.centos.noarch.rpm
yum-metadata-parser-*.rpm
yum-plugin-fastestmirror-*.rpm
python-iniparse-*.rpm
安装安装包
安装时需要注意顺序:
1、安装python-iniparse-*.rpm
2、安装yum-metadata-parser-*.rpm
3、然后是yum-*.centos.noarch.rpm和yum-plugin-fastestmirror-*.rpm一起安装
以下是以上图中的版本的安装命令
# 第一步
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
# 第二步
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
# 第三步
rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
补充镜像
运行makecache 生成缓存
yum makecache
运行yum clean all
yum clean all
更新yum文件
yum update
测试yum命令是否可用
yum install wget