当遇到这个问题的时候,发现网上也有很多人也在问同样的问题。但是发现大家问的问题,很少有人能解释得很清楚,而且很多人的解决方法复杂且不能解决问题。我查了近二十篇博客和文章,对照做了,但是基本解决不了问题。
http://mirrors.ustc.edu.cn/help/centos.html
http://mirrors.163.com/.help/centos.html
https://blog.csdn.net/dreamchasering/article/details/77160477
https://blog.csdn.net/shaoqiufeng/article/details/78785806
https://blog.csdn.net/orangleliu/article/details/40588799
https://www.cnblogs.com/yizhichun/p/6339742.html
https://blog.csdn.net/james_jr10/article/details/78357600(这个好像很厉害,但是写得不清晰,误我前程啊)
https://segmentfault.com/q/1010000000716991/a-1020000000717340
你来看看,这些问题有多少人问?但是能解决实际问题的却很少!!!
下面由我给出一种最简单最有效的方法。耐心看下去哦!
问题所在:
[root@cit-server6-s1-372 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
base | 5.6 kB 00:00:00
http://mirrors.163.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for base: Damaged repomd.xml file
Trying other mirror.
One of the configured repositories failed (CentOS-7 - Base - 163.com),
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. Disable the repository, 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
4. 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://mirrors.163.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for base: Damaged repomd.xml file
[root@cit-server6-s1-372 yum.repos.d]#
错误所在的问题:
主要问题在于yum源问题。
下面开始解决问题:
下面这一段参考博客:https://blog.csdn.net/shaoqiufeng/article/details/78785806
1. 查看centos7.2系统本身所安装的yum依赖包
[root@zf-test-web01-4 ~]# rpm -qa|grep yum
yum-plugin-fastestmirror-1.1.31-34.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-132.el7.centos.0.1.noarch
2. 卸载这些软件包
[root@zf-test-web01-4 ~]# rpm -e yum-plugin-fastestmirror-1.1.31-34.el7.noarch --nodeps
warning: /etc/yum/pluginconf.d/fastestmirror.conf saved as /etc/yum/pluginconf.d/fastestmirror.conf.rpmsave
[root@zf-test-web01-4 ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[root@zf-test-web01-4 ~]# rpm -e yum-3.4.3-132.el7.centos.0.1.noarch --nodeps
[root@zf-test-web01-4 ~]#
3. 进入centos镜像网站找到自己对应系统需要的yum包
查看系统的命令:
[root@zf-test-web01-4 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
查看系统的位数:
[root@zf-test-web01-4 ~]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=aa7ff68f13de25936a098016243ce57c3c982e06, stripped
4.下载yum依赖包
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.2.1511/os/x86_64/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
5. 安装yum依赖包
[root@zf-test-web01-4 ~]# rpm -ivh yum-*
Preparing... ################################# [100%]
Updating / installing...
1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 33%]
2:yum-plugin-fastestmirror-1.1.31-3################################# [ 67%]
3:yum-3.4.3-132.el7.centos.0.1 ################################# [100%]
[root@zf-test-web01-4 ~]#
6. 更新centos系统的repo文件(-----------------------------------------------------
http://mirrors.ustc.edu.cn/help/centos.html(这个很有用)
http://mirrors.163.com/.help/centos.html(这个我尝试了,不能正常使用)
这两个网址先写下来,后面要用,很重要!
------------------------------------------------------)
1)首先备份一下,免得误操作 /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.ustc.edu.cn/help/centos.html 现在这个网址用上了,可以说厉害了
什么?中科大校园网址?没错!
[root@zf-test-web01-4 yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup2)选择对应版本的 /etc/yum.repos.d/CentOS-Base.repo文件, 放入/etc/yum.repos.d/ 操作前请做好相应备份
如本人centos版本为7,所以使用版本7的内容。
拷贝上面这些内容,粘贴到yum.repos.d/CentOS-Base.repo里面。
3)运行以下命令生成缓存Metadata Cache Created
7. 尝试使用yum install vim能否成功安装。
8.如果还有问题就执行以下几个命令:
https://blog.csdn.net/orangleliu/article/details/40588799
参照网上的做法: (一般yum有变更都需要这两个操作)
yum clean all
yum clean metadata
yum update
9.所有的错误基本都ok了,突然感觉牛逼了,有木有?
转载请注明出处!https://blog.csdn.net/homewm/article/details/80642851