如果没有购买 Redhat 的服务, 或者服务已经过期, 在 Red Hat Enterprise Linux (RHEL) 用 yum 会出现以下错误:
|
1 2 3 4 5 6 7 |
# yum install pidgin Loaded plugins: rhnplugin, security This system is not registered with RHN. RHN support will be disabled. Setting up Install Process No package pidgin available. Nothing to do |
如果不想购买 Redhat 的服务, 可以很直接转用 CentOS Repository, 而且做法十分简单。
首先建立 CentOS Repository 的档案:
|
1 |
# vi /etc/yum.repos.d/CentOS.repo |
然后加入以下一行内容, 要留意的是, 以下是以 RHEL 6 为例子, 如果是其他 RHEL 版本, 例如 RHEL 7, 需要将下面的 “6” 改为 “7”.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[CentOS6 base] name=CentOS-6-Base mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [CentOS6 updates] name=CentOS-6-Updates mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [CentOS5plus] name=CentOS-6-Plus mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [centos] name=CentOS $releasever - $basearch baseurl=http://ftp.heanet.ie/pub/centos/6/os/$basearch/ enabled=1 gpgcheck=0 |
然后将 RHEL Repository 停用, 开启档案 /etc/yum.repos.d/RHEL-Base.repo, 将档案内所有 enabled 改为 0, 即是:
|
1 |
enabled=1 |
改为
|
1 |
enabled=0 |
接着汇入 CentOS 的 GPG key, 以下同样以 RHEL 为例子:
|
1 |
# rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 |
然后就可以用 yum 透过 CentOS Repository 更新及安装套件了。