1. 程式人生 > >問題_解決CentOS 5.5 yum源不能用的問題

問題_解決CentOS 5.5 yum源不能用的問題

問題描述

yum check-update的時候,總是提示錯誤。按照網上的方法做處理,結果提示各種錯誤,大致如下:

  • YumRepo Error: All mirror URLs are not using ftp, http[s] or file
  • Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons.
  • Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfi

試了網上解決方案,我的問題均未解決。最後自己試出來了,先說明下大概情況:
1.最新版的CentOS系統是7.4.1708,如圖
這裡寫圖片描述
2.國內的各大映象站只有最新版本目錄有內容,其他版本目錄下僅有readme檔案
3.各大映象站下載的CentOS-Base.repo檔案,放到/etc/yum.repos.d/下都用不了

解決方案

readme檔案中發現http://vault.centos.org/網站是有各個版本映象的,所以
1.通過lsb_release -a查詢下,系統版本如圖
這裡寫圖片描述
2.根據查詢資訊,將/etc/yum.repos.d/CentOS-Base.repo中baseurl路徑做調整,檔案內容如下:

# 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 baseurl=http://vault.centos.org/5.5/os/i386/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates baseurl=http://vault.centos.org/5.5/updates/i386/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #packages used/produced in the build but not released [addons] name=CentOS-$releasever - Addons baseurl=http://vault.centos.org/5.5/addons/i386/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras baseurl=http://vault.centos.org/5.5/extras/i386/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus baseurl=http://vault.centos.org/5.5/centosplus/i386/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib baseurl=http://vault.centos.org/5.5/contrib/i386/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

3.儲存檔案後,執行yum clean all
4.執行yum check-update測試下,ok

國內的幾個yum映象源

  1. http://ftp.sjtu.edu.cn/centos/,上海交大,但伺服器位於北京,中國教育網網路中心,我看像是朝陽區那邊的IP,以前在那邊上過 班,下載速度高達十M。 北方使用者與教育網使用者推薦,速度飛快。
  2. http://mirrors.sohu.com/,sohu的開源映象伺服器,伺服器位於山東省聯通。 速度飛快,全國使用者推薦,經常用FireFox下載CD映象。
  3. http://mirrors.163.com/centos,網易的開源伺服器映象 速度也不錯,全國使用者推薦. 下載CentOS-Base-163.repo, 放入/etc/yum.repos.d/