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 位部落客按了赞: