默认centos自带的源少了很多好软件,所以需要添加第三方源
一、安装CentOS yum源优先级插件yum-priorities
yum install yum-plugin-priorities.noarch
二、设置CentOS默认yum源的优先级为最高
cd /etc/yum.repos.d/ #进入yum源目录
vi CentOS-Base.repo #在[base]、[updates]、[extras]组下面添加priority=1,在[centosplus]、[contrib]组下面添加priority=2
################################################################
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=2
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=2
###############################################################
备注:priority的优先级为1到99,设置为1即优先级最高,1-10为系统保留,第三方yum源的优先级从11-99
当 Fedora 项目的维护人员发现可以采用管理 Fedora 项目的方法,来管理针对企业版 Linux 的附加软件包项目时,一个新的伟大的项目诞生了!项目诞生之初只是加入了一些在 RHEL 维护 Fedora 的工具。随着时间的发展,EPEL 仓库越来越丰富,成为一个大型的软件收集仓库
[root@localhost tmp]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
CentOS-Debuginfo.repo CentOS-Vault.repo epel-testing.repo
vi /etc/yum.repos.d/epel.repo (具体根据实际源目录地址,注意字母大小写,有的CENTOS系统是大小写交叉的)
#修改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
安装atomic yum源
wget http://www.atomicorp.com/installers/atomic #下载
sh ./atomic #安装
vi /etc/yum.repos.d/atomic.repo #修改atomic yum源优先级,priority=12
##############################################################
[atomic]
name = CentOS / Red Hat Enterprise Linux $releasever - atomicrocketturtle.com
mirrorlist = http://www.atomicorp.com/mirrorlist/atomic/centos-6-$basearch
#mirrorlist = http://www.atomicorp.com/channels/atomic/centos/6/mirrors-atomic
enabled = 1
priority = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
gpgcheck = 1
priority=12
##############################################################
添加163+网易源使用如下方法:
首先备份/etc/yum.repos.d/CentOS-Base.repo
Mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)
当然更简单的办法是wget
wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
然后运行yum makecache生成缓存
最后安装好第三方源时记得 更新yum软件包
yum check-update