如果没有购买 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 更新及安装套件了。
谢谢! 这篇有用! 这个方法简单又方便多了。其他人说要把RedHat原生的yum先移除掉根本是绕远路了!
hi sam
我使用RHEL6.7
照着步骤做到最后一步,但在Import的时候会出现Fail,请问是要怎么解决?
rpm –import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
你好, 首先确定有使用 root 身份执行 import 指令, 另外也要确定主机上网没有问题, 包括 Name Server 设定正确.
请问一下使用 RHEL但引用 CentOS Repository会不会有legal的问题? 还是一定要购买 Redhat 的服务?公司在询问因此要有较明确的回应,谢谢!
请问rhel 8怎么使用centos repo呢?谢谢