解決關於yum 下載報錯的問題[failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try. http]


背景: 我有時候用yum下載能成功,有時候確報錯,這讓下定徹底解決這個問題的心, 我當時推測引起的原因:可能yum的源參雜了其他不能用的源給污染了

解決:
1. 先卸載本機系統的yum源(我的是Centos7.8)

      rpm -aq|grep  yum

      rpm -e 搜出來的yum源  --nodeps ( --nodeps作用是過濾刪除時的詳情) 
 
 2.   根據自己系統版本找到centos官方鏡像站相對應的yum源

      # 查看本機centos版本
      cat /etc/centos-release  

      # 查看系統位數
      file /bin/ls

      # centos官方鏡像站: 
      http://mirrors.ustc.edu.cn/help/centos.html

      # 修改yum配置文件,注意:請先備份/etc/yum.repos.d/CentOS-Base.repo這個文件,  對於 CentOS 6、7,使用以下命令替換默認配置
      
       1. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
     ` 2. sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
       -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos|g' \
       -i.bak \
       /etc/yum.repos.d/CentOS-Base.repo
      `
    
  
     `


     # Centos7 修改 vi /etc/yum.repos.d/CentOS-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=https://mirrors.ustc.edu.cn/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=https://mirrors.ustc.edu.cn/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=https://mirrors.ustc.edu.cn/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=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
        gpgcheck=1
        enabled=0
        gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7


     # 這是centos官方鏡像站yum的依賴, 選擇自己的版本,我是把yum開頭的全下了
     https://mirrors.ustc.edu.cn/centos/7.8.2003/os/x86_64/Packages/

     wget https://mirrors.ustc.edu.cn/centos/7.8.2003/os/x86_64/Packages/yum-NetworkManager-dispatcher-1.1.31-53.el7.noarch.rpm
     wget https://mirrors.ustc.edu.cn/centos/7.8.2003/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
     wget https://mirrors.ustc.edu.cn/centos/7.8.2003/os/x86_64/Packages/yum-cron-3.4.3-167.el7.centos.noarch.rpm

    # 安裝yum依賴包:
    rpm -ivh |grep yum-**

3.  先清除yum緩存,然后再進行更新緩存
    yum  clean all
    yum  makecache
   
   # 試着yum下載看看,如果還不行,可以:
    yum  clean all 
    yum  clean metadata
    yum  update






   參考處:[https://blog.csdn.net/homewm/article/details/80642851]()


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM