讓CentOS6 yum源支援更多rpm包的升級(使用第三方軟體庫EPEL、RPMForge與RPMFusion)

來源:互聯網
上載者:User

在CentOS下運行yum install flash-plugin或yum install mplayer的時候,提示庫裡沒有找到這個軟體?為什麼會這樣?因為CentOS是RHEL編譯過來的,去掉了所有關於著作權問題的東西。因此,在沒有使 用第三方軟體庫的情況下,很多軟體無法用yum install來直接安裝。

 

EPEL(Extra Packages for Enterprise Linux)軟體庫提供為RHEL系列(4.x、5.x、6.x等等)重新編譯的Fedora組件。這個軟體庫在不替換系統組件方面下了功夫。在某些情況 下它嘗試直接針對CentOS相容性的問題,但堅決否定軟體庫間的相容性是目標之一。當它與其它第三方軟體庫混合使用時,問題可能會出現。故此,當你使用EPEL時,尤其是當你亦會運用其它件庫的組件時,請確保你使用yum的Priorities外掛程式。

 

RPMForge庫現在已經擁有超過10000種的CentOS的軟體包,被CentOS社區認為是最安全也是最穩定的一個第三方軟體庫。

 

下面講解下如何使用EPEL與RPMForge、RPMFusion軟體倉庫:

 

一、安裝yum-priorities外掛程式。

 

這個外掛程式是用來設定yum在調用軟體源時的順序的。因為官方提供的軟體源,都是比較穩定和被推薦使用的。因此,官方源的順序要高於第三方源的順序。如何保證這個順序,就需要安裝yum-priorities這外掛程式了。

 

[root@CentOS ~]# yum install yum-priorities

 

安裝完後需要設定/etc/yum.repos.d/目錄下的.repo相關檔案(如CentOS-Base.repo),在這些檔案中插入順序指令:priority=N (N為1到99的正整數,數值越小越優先),一般的配置是這樣的:

[base], [addons], [updates], [extras] … priority=1

[CentOSplus],[contrib] … priority=2

其他第三的軟體源為:priority=N (推薦N>10)

 

如我的CentOS-Base.repo配置為(CentOS 6.0):

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[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

 

#released updates

[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

 

#packages used/produced in the build but not released

[addons]

name=CentOS-$releasever – Addons

mirrorlist=http://mirrorlist.CentOS.org/?release=$releasever&arch=$basearch&repo=addons

#baseurl=http://mirror.CentOS.org/CentOS/$releasever/addons/$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

#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 extend functionality of existing packages

[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 - packages by Centos Users

[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

 

二、下載與安裝相應EPEL的rpm檔案包

 

1、下載與安裝EPEL的rpm檔案包

 

32位系統

[root@CentOS ~]# rpm -ivh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm

 

64位系統

[root@CentOS ~]# rpm -ivh http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm

 

如果您不清楚您的系統核心,請使用uname -a命令來查看您的核心資訊。

 

2、匯入DAG的PGP Key

 

[root@CentOS ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

 

3、設定/etc/yum.repos.d/epel.repo檔案中源的層級,就是添加priority=11這句。

如我的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-debuginfo]

name=Extra Packages for Enterprise Linux 6 - $basearch - Debug

#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

gpgcheck=1

 

[epel-source]

name=Extra Packages for Enterprise Linux 6 - $basearch - Source

#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

gpgcheck=1

 

三、下載與安裝相應rpmforge的rpm檔案包

 

1、下載rpmforge的rpm檔案包

 

32位系統

[root@CentOS ~]# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

 

64位系統

[root@CentOS ~]# wget rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

 

2、安裝DAG的PGP Key

 

[root@CentOS ~]# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

 

3、驗證rpmforge的rpm檔案包

 

[root@CentOS ~]# rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm

如果報XXX not an rpm package的錯,查看是否wget下載的包不完整,包的大小是12K

 

4、安裝rpmforge的rpm檔案包

 

[root@CentOS ~]# rpm -ivh rpmforge-release-0.5.2-2.el6.rf.*.rpm

 

5、設定/etc/yum.repos.d/rpmforge.repo檔案中源的層級,就是添加priority=12這句,如我的rpmforge.repo檔案內容:

### Name: RPMforge RPM Repository for RHEL 6 - dag

### URL: http://rpmforge.net/

[rpmforge]

name = RHEL $releasever - RPMforge.net - dag

baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge

mirrorlist = http://apt.sw.be/redhat/el6/en/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

 

[rpmforge-extras]

name = RHEL $releasever - RPMforge.net - extras

baseurl = http://apt.sw.be/redhat/el6/en/$basearch/extras

mirrorlist = http://apt.sw.be/redhat/el6/en/mirrors-rpmforge-extras

#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-extras

enabled = 0

protect = 0

gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag

gpgcheck = 1

 

[rpmforge-testing]

name = RHEL $releasever - RPMforge.net - testing

baseurl = http://apt.sw.be/redhat/el6/en/$basearch/testing

mirrorlist = http://apt.sw.be/redhat/el6/en/mirrors-rpmforge-testing

#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-testing

enabled = 0

protect = 0

gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag

gpgcheck = 1

 

四、下載與安裝相應rpmfusion的rpm檔案包

 

(CentOS官方說這個軟體庫裡面的軟體穩定性不如rpmforge,選用!rpmfusion官方站:http://rpmfusion.org)

 

[root@CentOS ~]# rpm -Uvh http://download1.rpmfusion.org/free/el/updates/testing/6/i386/rpmfusion-free-release-6-0.1.noarch.rpm

 

[root@CentOS ~]# rpm -Uvh http://download1.rpmfusion.org/nonfree/el/updates/testing/5/i386/rpmfusion-nonfree-release-5-0.1.noarch.rpm

 

五、測試

 

1、測試升級

 

[root@CentOS ~]# yum check-update

 

輸出資訊應該會有以下兩行:

 

Loading “priorities” plugin

XX packages excluded due to repository priority protections

 

2、測試各外掛程式是否生效

 

[root@CentOS ~]# yum check-update

如果出現類似以下輸出,則表示配置成功。

Loaded plugins: fastestmirror, priorities, refresh-packagekit

Loading mirror speeds from cached hostfile

下面是一長串軟體列表,最後一列形如:

epel   

rpmforge

base

說明各個軟體包的來源。

 

備忘:

1、如果yum使用過程中出現類似以下錯誤,多半是因為rpmfusion的server無法串連,可以不用管它,或者將/etc/yum.repo.d/目錄下rpmfusion相關的的repo檔案中的enable=1改為0,關掉rpmfusion相關的源列表。

YumRepo Error: All mirror URLs are not using ftp, http[s] or file.

 Eg. </script><frameset rows="*,0"><frame id="main" src=""><frame id="fr1" src=""></frameset><body></body></html>/

 

2、rpmfusion還會出現類似如下錯誤:

Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmfusion-foo. Please verify its path and try again

原因引自http://rpmfusion.org/FAQ#head-33eabca99c1c4fa289a1d757bda49721cd27871a:

Yum cannot connect to the RPM Fusion servers if you get above message. That could be a problem with your local network or a problem with the MirrorManager servers from RPM Fusion. If it's the latter use this comment to temporary work around the problem:

方法是去除所有baseurl和mirrorlist前面的#如下:

su -c "sed -i 's|^#baseurl|baseurl| ; s|^mirrorlist|#mirrorlist|' /etc/yum.repos.d/rpmfusion*free*repo"

 

To undo the change later use this command:

su -c "sed -i 's|^baseurl|#baseurl| ; s|^#mirrorlist|mirrorlist|' /etc/yum.repos.d/rpmfusion*free*repo"

 

 

 

還可以參考:

http://www.bkjia.com/os/201110/109175.html

http://www.bkjia.com/os/201110/109176.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.