目的:Centos/RHEL默认的yum软件仓库里软件包非常有限,仅仅限于发行版本那几张盘里面的常规包和一些软件包的更新,利用RpmForge,可以增加非常多的第三方rpm软件包。RpmForge库现在已经拥有超过10000种的CentOS的软件包,被CentOS社区认为是最安全也是最稳定的一个第三方软件库。
一、安装yum-priorities插件
这个插件是用来设置yum在调用软件源时的顺序的。因为官方提供的软件源,都是比较稳定和被推荐使用的。因此,官方源的顺序要高于第三方源的顺序。如何保证这个顺序,就需要安装yum-priorities这插件了。
# yum -y install yum-priorities
二、安装完yum-priorities插件后需要设置/etc/yum.repos.d/ 目录下的.repo相关文件(如CentOS6-Base-163.repo),在这些文件中插入顺序指令:priority=N (N为1到99的正整数,数值越小越优先);
一般配置[base], [updates], [extras] 的priority=1,[centosplus], [contrib] 的priority=2,其他第三的软件源为priority=N (推荐N>10)
# vim /etc/yum.repo.CentOS6-Base-163.repo
###############################################################
[base]
name=CentOS-6.5 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
#released updates
[updates]
name=CentOS-6.5 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
#additional packages that may be useful
[extras]
name=CentOS-6.5 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.5 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=2
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.5 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=2
###############################################################
PS:priority的优先级为1到99,设置为1即优先级最高,1-10为系统保留,第三方yum源的优先级从11-99
三、安装epel yum源
# rpm -ivh http://mirrors.opencas.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
# vim /etc/yum.repos.d/epel.repo #修改epel yum源优先级,priority=11
###############################################################
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
priority=11
#################################################################
四、安装rpmforge yum源
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
# rpm -K rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm ###验证rpmforge的rpm文件包
# rpm --import RPM-GPG-KEY.dag.txt
# rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
# vim /etc/yum.repos.d/rpmforge.repo ###修改rpmforge yum源优先级,priority=12
#################################################################
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
priority=12
#################################################################
五、安装rpmfusion yum源
# wget http://download1.rpmfusion.org/free/el/updates/6/x86_64/rpmfusion-free-release-6-1.noarch.rpm
# rpm -ivh rpmfusion-free-release-6-1.noarch.rpm
# 修改rpmfusion yum源优先级,priority=13
# vim /etc/yum.repos.d/rpmfusion-free-updates.repo
#################################################################
[rpmfusion-free-updates]
name=RPM Fusion for EL 6 - Free - Updates
#baseurl=http://download1.rpmfusion.org/free/el/updates/6/$basearch/
mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-el-updates-released-6&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-free-el-6
priority=13
#################################################################
六、安装atomic yum源
# wget http://www.atomicorp.com/installers/atomic
# sh ./atomic #安装
# vim /etc/yum.repos.d/atomic.repo #修改atomic yum源优先级,priority=14
##############################################################
[atomic]
name = CentOS / Red Hat Enterprise Linux $releasever - atomicrocketturtle.com
mirrorlist = http://updates.atomicorp.com/channels/mirrorlist/atomic/centos-6-$basearch
enabled = 1
priority = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
file:///etc/pki/rpm-gpg/RPM-GPG-KEY.atomicorp.txt
gpgcheck = 1
priority=14
##############################################################
七、更新yum软件包
# yum check-update
八、安装iftop
# yum install iftop
PS:至此,第三方软件库的yum源配置完成,现在你可以用yum命令安装自己需要的软件了。