CentOS添加第三方源

默認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   #生成緩存

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章