默认centos自带的源少了很多好软件,所以需要添加第三方源。
1.安装yum源优先级插件yum-priorities
#yum install yum-plugin-priorities.noar
#yum install yum-plugin-fastestmirror
2.设置CentOS默认yum源的优先级为最高
[root@Cacti yum.repos.d]#cd /etc/yum.repos.d
[[email protected]]# vi CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1
#additional packages that extendfunctionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#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 - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
#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
#在[base]、[updates]、[extras]组下面添加priority=1,在[centosplus]、[contrib]组下面添加priority=2
3.安装EPEL源。
安装EPEL可采用两种方式:
第一种采用yum方式:
[root@Cacti ~]# yum install epel-release
…..
第二种方式: 采用rpm命令安装
[root@Cacti tools]# cat /etc/redhat-release #查看操作系统版本
CentOS release 6.8 (Final)
[root@Cacti tools]# rpm -qa epel-release
epel-release-6-8.noarch
[root@Cacti tools]# rpm –e epel-release #卸载
[root@Cacti tools]# rpm -ivhepel-release-6-8.noarch.rpm #找对应的操作系统版本安装
warning: epel-release-6-8.noarch.rpm:Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
另一种方式下载对应系统的最新包,例如:CentOS6.0
#wget http://mirrors.ustc.edu.cn/epel/epel-release-latest-6.noarch.rpm
#rpm -ivh epel-release-latest-6.noarch.rpm
[root@Cacti ~]# yum clean all && yum makecache #生成缓存
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/metalink |4.7 kB 00:00
*base: mirrors.163.com
* epel: mirrors.ustc.edu.cn
*extras: mirrors.163.com
*updates: mirrors.163.com
……
[root@Cacti yum.repos.d]# vi /etc/yum.repos.d/epel.repo
[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 #修改epel yum源优先级,priority=11
4.安装Atomic源。
[root@Cacti tools]# wget http://www.atomicorp.com/installers/atomic
[root@Cacti tools]# sh ./atomic
#vi /etc/yum.repos.d/atomic.repo #修改atomic yum源优先级,priority=14
[atomic]
name = CentOS /Red Hat Enterprise Linux $releasever - atomic
mirrorlist =http://updates.atomicorp.com/channels/mirrorlist/atomic/centos-$rel
easever-$basearch
enabled = 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
备注:priority的优先级为1到99,设置为1即优先级最高,1-10为系统保留,第三方yum源的优先级从11-99
[root@Cacti ~]# yum clean all && yum makecache #生成缓存