yum無法使用解決方法(比較全,以后如果遇到別的問題還會添加)


  • 如下,新裝的linux虛擬機,yum安裝wget報錯

Cannot find a valid baseurl for repo: base/7/x86_64
[root@baty opt]# yum install wget
已加載插件:fastestmirror
Determining fastest mirrors

 One of the configured repositories failed (未知),
 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=<repoid> ...

     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 <repoid>
        or
            subscription-manager repos --disable=<repoid>

     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=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

解決方法1: 最簡單粗暴的方法就是把/etc/yum.repos.d下的文件全部刪除,然后將能正常使用yum的同類服務器的這個目錄下的文件全部拷貝過來,然后yum clean all 和yum makecache 即可(這是之前我研究了很久這個問題之后一個大佬告訴我的,如果急需使用yum可以用這個方法!當然,最好還是備份文件夾之后再刪除,以免發生意外,這個說多了都是淚!)

解決方法2:有網友說修改/etc/yum/pluginconf.d/fastestmirror.conf  配置文件的enable=1 改成enable=0 , 以及修改/ect/yum.conf  將plugins=1改成0 (當然我通過這個方法沒有解決)

解決方法3:更換yum源,然后一搜換源都是 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo    大哥我就是yum install wget報的錯,你讓我去哪里用wget! 然后我想到了直接下載拷貝上來。下面是操作方法。

解決辦法:安裝這個源
下載地址:https://pan.baidu.com/s/1pKBtm11
提取密碼:erte
[root@bastion-IDC yum.repos.d]# rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
-------------------------------------------------------------------------------------------------------------

[root@bastion-IDC yum.repos.d]# yum clean all
[root@bastion-IDC yum.repos.d]# yum makecache //將服務器上的軟件包信息緩存到本地,以提高搜索安裝軟件的速度
[root@bastion-IDC yum.repos.d]# yum update

最后再次使用yum就ok了

解決方法4:之前提到/etc/yum.repos.d 這個文件夾 ,進入這個文件夾之后發現有幾個文件

問題就出在這個CentOS-Base.repo上面,有說因為這個文件的問題 ,通過mv命令修改使這文件無效就行。(我也是沒有行得通,賊氣)

解決方法5:有人說網卡設置的問題,橋接模式改為NAT模式就能成功

Cannot find a valid baseurl for repo: base/7/x86_64這個錯誤是因為虛擬機連不上外網,不信的可ping www.baidu.com 看看能不能通,如果是這個原因的話修改虛擬機模式
從橋接模式變為NAT模式就可以解決問題。(如果虛擬機能連上外網的話請看1-4的解決方法)

思考: 我也就納悶為啥我裝新的虛擬機會這樣的情況,換了源,或者直接替換掉/ect/yum.repos.d 這個文件夾,就可以用,后來想到了有個東西叫做牆。

iso鏡像里面的yum引用的是國外的源,如果vpn到期了,或者是被牆了,是不是就安裝失敗了呢? 我換了幾個國內的源測試都可以用,就保留的最初的源不可用。所以最后問題找到了。牆!

 




 
       


免責聲明!

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



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