yum 報404 解決辦法


yum報錯如下

[root@java152 ~]# yum makecache
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cloud.aliyuncs.com
 * extras: mirrors.cloud.aliyuncs.com
 * updates: mirrors.cloud.aliyuncs.com
http://mirrors.aliyun.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在嘗試其它鏡像。
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/.

base                                                                                                         | 1.0 kB  00:00:00     
http://mirrors.cloud.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for base: Damaged repomd.xml file
正在嘗試其它鏡像。
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30000 milliseconds')
正在嘗試其它鏡像。
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
正在嘗試其它鏡像。
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
正在嘗試其它鏡像。
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
正在嘗試其它鏡像。
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
正在嘗試其它鏡像。
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
正在嘗試其它鏡像。


 One of the configured repositories failed (CentOS-$releasever - Base - mirrors.aliyun.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. 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://mirrors.aliyun.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for base: Damaged repomd.xml file
http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30000 milliseconds')
http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')
http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30001 milliseconds')

 

 

1.修改DNS,失敗告終。(還是不能用)

命令:vim /etc/sysconfig/network-scripts/ifcfg-eth0

vim /etc/sysconfig/network-scripts/ifcfg-eth0

vim /etc/sysconfig/network-scripts/ifcfg-eth0

 

2.重裝yum服務,還是不能用。
yum-3.4.3-161.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

 命令:rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm --nodeps --force           //nodeps 強制安裝    force 避免依賴
 命令:rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --nodeps --force
 命令:rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm --nodeps --force

3.更新yum源,失敗告終。

命令:mv /etc/yum.repos.d/*  /etc/yum.repos.d/backup.bak
命令:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo     //指向阿里源
命令:yum clean all                            //清除緩存
命令:yum makecache                      //生成緩存

最終解決方法

上邊一直提示 404 錯誤,然后我直接訪問
http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml
發現這個地址打不開

命令:vim /etc/yum.repos.d/Centos-7.repo

命令::%s/$releaserver/7/g                                #文本編輯器中的替換命令

 

 修改完之后執行

命令:yum  makecache                         #OK

 

 

知識擴展:

問題分析一下

對比.repo文件和報錯信息,可以發現$releasever變量沒有被系統識別,在連接網絡yum源的時候,變成了%24releasever

 

查詢資料得知,yum中的變量$releasever是由/etc/yum.conf中的distroverpkg定義的。centos-release為一個rpm包,所謂“distroverpkg=centos-release”的意思,其實是將 $releasever設置為centos-release 這個RPM包的版本號
所以打開yum的配置文件

命令:vim /etc/yum.conf

 通過rpm可以查詢到改軟件包並沒有被安裝

 

 

解決思路

由於centos-release依賴關系比較復雜,約40個左右依賴包,我們可以修改yum源文件,把$releasever全部替換為7(上邊已操作)

 

 此時yum可以正常使用,通過yum安裝centos-release

命令:yum -y install centos-release

重新下載yum源,覆蓋修改之后的yum。yum makecache系統可把$releasever解析為當前的CentOS的版本,恢復正常狀態

 

 

總結:。。。。。。。。。。(此處省略一萬字)


免責聲明!

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



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