CentOS 5/6 改為可用的 yum 套件庫來源 (2022)

若執行 yum 出現:

http://mirror.centos.org/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
To address this issue please refer to the below knowledge base article

表示系統預設的 yum 套件庫可能已經不存在!

我們可以在 vault.centos.org 找到可用的套件庫來源:

  • vault.centos.org: http
  • archive.kernel.org: http - rsync (rsync://archive.kernel.org::centos-vault/)
  • linuxsoft.cern.ch: http - rsync (rsync://linuxsoft.cern.ch/centos-vault/)
  • mirror.nsc.liu: http - rsync (rsync://mirror.nsc.liu.se::centos-store/)

CentOS 6.x

編輯 /etc/yum.repos.d/CentOS-Base.repo,將全部的內容改為 vault.centos.org 套件庫:

[base]
name=CentOS-$releasever - Base
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=https://vault.centos.org/6.10/os/$basearch/
gpgcheck=0
enabled=1

#released updates
[updates]
name=CentOS-$releasever - Updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=https://vault.centos.org/6.10/updates/$basearch/
gpgcheck=0
enabled=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=https://vault.centos.org/6.10/extras/$basearch/
gpgcheck=0
enabled=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=https://vault.centos.org/6.10/centosplus/$basearch/
gpgcheck=0
enabled=0

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
baseurl=https://vault.centos.org/6.10/contrib/$basearch/
gpgcheck=0
enabled=0

查看套件庫:

$ yum clean all
$ yum repolist
 Loaded plugins: fastestmirror, refresh-packagekit
 Loading mirror speeds from cached hostfile
 repo id  repo name          status
 base     CentOS-6 - Base     6,713
 extras   CentOS-6 - Extras      47
 updates  CentOS-6 - Updates  1,193
 repolist: 7,953

這樣就可以恢復使用了。

若之後 vault.centos.org 也無法使用,可以替換網址為其它剩下的套件庫。

 

CentOS 5.x

編輯 /etc/yum.repos.d/CentOS-Base.repo,將全部的內容改為 archive.kernel.org 套件庫:

[base]
name=CentOS-$releasever - Base
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://archive.kernel.org/centos-vault/5.11/os/$basearch/
gpgcheck=0
enabled=1

#released updates
[updates]
name=CentOS-$releasever - Updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://archive.kernel.org/centos-vault/5.11/updates/$basearch/
gpgcheck=0
enabled=1

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
baseurl=http://archive.kernel.org/centos-vault/5.11/addons/$basearch/
gpgcheck=0
enabled=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=http://archive.kernel.org/centos-vault/5.11/extras/$basearch/
gpgcheck=0
enabled=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=http://archive.kernel.org/centos-vault/5.11/centosplus/$basearch/
gpgcheck=0
enabled=0

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
baseurl=http://archive.kernel.org/centos-vault/5.11/contrib/$basearch/
gpgcheck=0
enabled=0

查看套件庫:

$ yum clean all
$ yum repolist
 Loaded plugins: fastestmirror
 Loading mirror speeds from cached hostfile
 Excluding Packages in global exclude list
 Finished
 repo id repo name status
 addons   CentOS-5 - Addons         0
 base     CentOS-5 - Base    2,781+10
 extras   CentOS-5 - Extras       272
 updates  CentOS-5 - Updates  660+150
 repolist: 3,713

這樣就可以恢復使用了。

PS. 其實 CentOS 5.x 也可以如同 CentOS 6.x 將套件庫的來源設為「https://vault.centos.org/5.11」,但是執行 yum 會出現如下的 SSL 錯誤:

Traceback (most recent call last):
 File "/usr/bin/yum", line 29, in ?
 yummain.user_main(sys.argv[1:], exit_code=True)
 ...
 return m2.ssl_connect(self.ssl, self._timeout)
 M2Crypto.SSL.SSLError: unknown protocol

因此才改用「http://archive.kernel.org/centos-vault/5.11

 

重建 rpm 資料庫

$ yum clean all
$ rm -f /var/lib/rpm/__db*
$ rpm --rebuilddb

 

錯誤處理

若 yum 出現下列訊息:

error was 14: problem making ssl connection

當試執行下列套件的更新:

$ yum update yum curl ca-certificates openssl nss

 

CentOS ISO 檔下載

v5.11:

v6.10:

v7.9:

 

參考網頁

  1. No comments yet.

  1. No trackbacks yet.

return top

%d 位部落客按了讚: