2017年8月25日 星期五

Centos5.x執行yum出現Error: Cannot find a valid baseurl for repo: base

家裡有一台很久的測試機,當初安裝Centos 5.11,最近想要安裝測試一些新功能時,卻發現yum竟然出錯

錯誤訊息:
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/
removing mirrorlist with no valid mirrors: /var/cache/yum/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

原來Centos 5.X版本太舊,所以Mirror site認為5.X的檔案已經不需要,就把5.X的檔案都刪除了

解決方法也很簡單,既然 Mirror site 沒有5.X的檔案,那就直接去找源頭

1. 編輯CentOS-Base.repo這個檔案

vim /etc/yum.repos.d/CentOS-Base.repo

2. 裡面有五個區段,每個區段都有一個mirrorlist的選項


[base]

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

[updates]
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

[extras]
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

[centosplus]
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

[contrib]
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib

將五個mirrorlist前頭加上#號註解掉它

3. 接著在每個區段增加baseurl的選項,指定去源頭抓檔案

[base]

baseurl=http://vault.centos.org/5.11/os/$basearch

[updates]
baseurl=http://vault.centos.org/5.11/updates/$basearch

[extras]
baseurl=http://vault.centos.org/5.11/extras/$basearch

[centosplus]
baseurl=http://vault.centos.org/5.11/centosplus/$basearch

[contrib]
baseurl=http://vault.centos.org/5.11/contrib/$basearch

4. 修改完記得儲存

接著執行yum update就會發現已經可以正常運作了


沒有留言:

張貼留言