1. 程式人生 > >Centos7系統安裝yum遇到的問題failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try. http:

Centos7系統安裝yum遇到的問題failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try. http:

當遇到這個問題的時候,發現網上也有很多人也在問同樣的問題。但是發現大家問的問題,很少有人能解釋得很清楚,而且很多人的解決方法複雜且不能解決問題。我查了近二十篇部落格和文章,對照做了,但是基本解決不了問題。

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

你來看看,這些問題有多少人問?但是能解決實際問題的卻很少!!!

下面由我給出一種最簡單最有效的方法。耐心看下去哦!

問題所在:

[[email protected] 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
[
[email protected]
yum.repos.d]#

錯誤所在的問題:



主要問題在於yum源問題。

下面開始解決問題:

下面這一段參考部落格:https://blog.csdn.net/shaoqiufeng/article/details/78785806

1. 檢視centos7.2系統本身所安裝的yum依賴包

[[email protected] ~]# 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. 解除安裝這些軟體包

[[email protected] ~]# 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
[[email protected] ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[[email protected] ~]# rpm -e yum-3.4.3-132.el7.centos.0.1.noarch --nodeps
[[email protected] ~]# 

3. 進入centos映象網站找到自己對應系統需要的yum包

    檢視系統的命令:

[[email protected]1-4 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core) 

   檢視系統的位數:

[[email protected] ~]# 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依賴包
[[email protected] ~]# 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%]

[[email protected] ~]# 

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    現在這個網址用上了,可以說厲害了

什麼?中科大校園網址?沒錯!

[[email protected] yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2)選擇對應版本的 /etc/yum.repos.d/CentOS-Base.repo檔案, 放入/etc/yum.repos.d/   操作前請做好相應備份

如本人centos版本為7,所以使用版本7的內容。


拷貝上面這些內容,貼上到yum.repos.d/CentOS-Base.repo裡面。

3)執行以下命令生成快取
[[email protected] yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[[email protected] yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
base                                                             | 3.6 kB  00:00:00     
extras                                                           | 3.4 kB  00:00:00     
updates                                                          | 3.4 kB  00:00:00     
(1/12): base/7/x86_64/group_gz                                   | 156 kB  00:00:00     
(2/12): base/7/x86_64/filelists_db                               | 6.7 MB  00:00:01     
(3/12): extras/7/x86_64/prestodelta                              |  71 kB  00:00:00     
(4/12): extras/7/x86_64/primary_db                               | 145 kB  00:00:00     
(5/12): extras/7/x86_64/filelists_db                             | 528 kB  00:00:00     
(6/12): extras/7/x86_64/other_db                                 |  97 kB  00:00:00     
(7/12): updates/7/x86_64/prestodelta                             | 589 kB  00:00:00     
(8/12): base/7/x86_64/primary_db                                 | 5.7 MB  00:00:01     
(9/12): base/7/x86_64/other_db                                   | 2.5 MB  00:00:00     
(10/12): updates/7/x86_64/primary_db                             | 4.5 MB  00:00:00     
(11/12): updates/7/x86_64/other_db                               | 490 kB  00:00:00     
(12/12): updates/7/x86_64/filelists_db                           | 2.7 MB  00:00:01     
Determining fastest mirrors

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