YUM應用終極攻略(轉載)

如果您要轉摘此文章,請註明出處:YUM應用終極攻略-麥麥的不老閣

本文以fedora10發行版爲例,如果使用的是低於10版本的,可能需要修改一些內容。
先以我係統中的yum.conf文件,說明一下大概的參數配置,很多文章都會說如何用YUM,但是很少見到說有如何配置yum.conf的。

[marco.chan@fedora ~]$ cat /etc/yum.conf
[main]
cachedir=/var/cache/yum #yum下載的RPM包的緩存目錄
keepcache=0 #緩存是否保存,1保存,0不保存。
debuglevel=2 #調試級別(0-10),默認爲2(具體調試級別的應用,我也不瞭解)。
logfile=/var/log/yum.log #yum的日誌文件所在的位置
exactarch=1 #在更新的時候,是否允許更新不同版本的RPM包,比如是否在i386上更新i686的RPM包。
obsoletes=1 #這是一個update的參數,具體請參閱yum(8),簡單的說就是相當於upgrade,允許更新陳舊的RPM包。
gpgcheck=1 #是否檢查GPG(GNU Private Guard),一種密鑰方式簽名。
plugins=1 #是否允許使用插件,默認是0不允許,但是我們一般會用yum-fastestmirror這個插件。
installonly_limit=3 #允許保留多少個內核包。
exclude=selinux* #屏蔽不想更新的RPM包,可用通配符,多個RPM包之間使用空格分離。
# This is the default, if you make this bigger yum won’t see if the metadata
# is newer on the remote and so you’ll “gain” the bandwidth of not having to
# download the new metadata and “pay” for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don’t keep old packages around. If you don’t like this checking
# interupting your command line usage, it’s much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE or IN separate files named file.repo
# in /etc/yum.repos.d

repo文件中的內容可以包含在yum.conf文件中,但是默認會放在/etc/yum.repos.d/這個目錄下,方便編輯,也爲了方便區分不同源的文件。

然後看一下我係統中的.repo:

[marco.chan@fedora ~]$ ls /etc/yum.repos.d/ -l
-rw-r–r– 1 root root 962 2009-03-14 16:57 fedora-asia-release.repo
-rw-r–r– 1 root root 738 2009-03-14 16:57 fedora-asia-update.repo
-rw-r–r– 1 root root 153 2009-03-14 19:46 fedora-dvdiso.repo
-rw-r–r– 1 root root 317 2009-03-15 13:10 fedora-redhat-release.repo
-rw-r–r– 1 root root 317 2009-03-15 13:11 fedora-redhat-update.repo
-rw-r–r– 1 root root 316 2009-03-15 20:21 fedora-second-depository-release.repo
-rw-r–r– 1 root root 263 2009-03-14 23:10 fedora-second-depository-updates.repo
-rw-r–r– 1 root root 1126 2009-01-15 23:50 jpackage17.repo
-rw-r–r– 1 root root 1035 2007-06-06 01:45 planetccrma.repo
#以上9個是我自己添加的.repo和相對陌生的第三方源文件。以下是系統默認的以及rpmfusion的源。
-rw-r–r– 1 root root 1963 2009-03-14 15:29 fedora-rawhide.repo
-rw-r–r– 1 root root 1093 2009-03-14 23:43 fedora.repo
-rw-r–r– 1 root root 1267 2009-03-15 14:55 fedora-updates.repo
-rw-r–r– 1 root root 1181 2008-11-07 04:06 fedora-updates-testing.repo
-rw-r–r– 1 root root 1022 2009-03-14 16:56 rpmfusion-free-rawhide.repo
-rw-r–r– 1 root root 1079 2009-03-14 15:30 rpmfusion-free.repo
-rw-r–r– 1 root root 1134 2009-03-14 15:30 rpmfusion-free-updates.repo
-rw-r–r– 1 root root 1194 2008-11-03 21:15 rpmfusion-free-updates-testing.repo
-rw-r–r– 1 root root 1067 2008-11-15 18:29 rpmfusion-nonfree-rawhide.repo
-rw-r–r– 1 root root 1124 2009-03-14 15:30 rpmfusion-nonfree.repo
-rw-r–r– 1 root root 1179 2009-03-14 15:30 rpmfusion-nonfree-updates.repo
-rw-r–r– 1 root root 1239 2008-11-03 21:18 rpmfusion-nonfree-updates-testing.repo

yum加速,關於yum的加速無非就是選擇一個快速的源,或者是多線程下載(yum本身是單線程):
方法一、安裝yum-fastestmirror這個插件.
說明:這個插件的效果並非和描述的那樣好“自動選擇最快的源”。其實yum-fastestmirror使用簡單的ping方式,以延時的大小來判斷源主機是否是最快的源,實際上這方法並不可靠。
安裝:

sudo yum -y install yum-fastestmirror

如果你仔細觀察過yum的話,我們大陸用戶基本會選擇到臺.灣的主機作爲最快的源,而實際上根據我個人的經驗,臺灣的源一般都跟蝸牛似的。所以我選擇了屏蔽了.tw的源,屏蔽的方式爲:

sudo vi /etc/yum/pluginconf.d/fastestmirror.conf
添加這一句:exclude=.tw, .twaren.net

方法二、安裝yum-axelget。
說明:yum是單線程下載的,而axel是一個多線程下載軟件。yum-axelget在yum運行的時候,自動調用axel來多線程下載,從而達到加速的目的。
安裝:使用rpm命令安裝axel,yum-axelget。點擊下載此文件

方法三、安裝yum-presto。關於presto請連接
用戶只需要下載每一個軟件的增量內容(用drpm打包而成),在本地計算機重新生成一個完整的軟件包再安裝。通常增量更新只有很小的下載量,因而即使很大 量的內容要更新,所耗費的時間必然比傳統方法要少很多。不過presto系統還在測試之中,而且只有一個服務器提供presto更新,速度也不怎麼樣。目 前 presto只提供Fedora 9、Fedora 10和Fedora Rawhide三個版本的更新。

sudo yum -y install yum-presto

Installation
In Fedora, run “yum install yum-presto”. Then enable a presto repository listed below.
Presto Repositories
To use presto in Fedora, you need to have some presto repositories enabled.
Easy setup:
The easy way (if you’re running F9 or F10 (i386, x86_64)) is to change the mirrorlist

For F9, in /etc/yum.repos.d/fedora-updates-newkey.repo change the mirrorlist to:
mirrorlist=http://presto-mirrors.anmar.eu.org/mirrorlist?repo=updates-released-f$releasever.newkey&arch=$basearch

For F10, in /etc/yum.repos.d/fedora-updates.repo change the mirrorlist to:
mirrorlist=http://presto-mirrors.anmar.eu.org/mirrorlist?repo=updates-released-f$releasever&arch=$basearch
Hard setup:

If you prefer to set the baseurl directly, use the following:

Fedora Rawhide:
To use the presto repository in Fedora Rawhide, you need to change your baseurl in /etc/yum.repos.d/fedora-rawhide.repo to point to the one below.
i386: baseurl=http://lesloueizeh.com/devel/i386/development

Fedora 10:
To use the presto repository in Fedora 10, you need to change your baseurl in /etc/yum.repos.d/fedora-updates.repo to point to the one below.
i386: baseurl=http://lesloueizeh.com/f10/i386/updates
x86_64: baseurl=http://dl.anmar.eu.org/repos/f10/updates-x86_64
A big thank you to Angel Marin for creating and hosting the x86_64 deltarpms for F10!

Fedora 9:
To use the presto repository in Fedora 9, you need to change your baseurl in /etc/yum.repos.d/fedora-updates-newkey.repo to point to the one below.
i386: baseurl=http://lesloueizeh.com/f9/i386/updates.newkey
x86_64: baseurl=http://dl.anmar.eu.org/repos/f9/updates-x86_64.newkey
A big thank you to Angel Marin for creating and hosting the x86_64 deltarpms for F9!
Releases:
Fedora 9, 10 and Rawhide

方法三、挑選自己滿意的源。
以附件形式放上來!點擊下載此文件

方法四、安裝專門的第三方源。
對於一些國內的源,大都只適合教育網用戶,因爲我不是教育網用戶,所以無法測試,我自己只用了上海交大自由軟件(free software)資源鏡像這一個。另外,大家期待163mirrors,除了fedoar ISO之外,並沒有同步其他的RPM包。
1、Planetccrma
http://ccrma.stanford.edu/planetccrma/software/
安裝:
http://ccrma.stanford.edu/planetccrma/software/installplanetnine.html
For Fedora 9:
rpm -Uvh http://ccrma.stanford.edu/planetccrma/mirror/fedora/linux/planetccrma/9/i386/planetccrma-repo-1.1-2.fc9.ccrma.noarch.rpm

For Fedora 10:
rpm -Uvh http://ccrma.stanford.edu/planetccrma/mirror/fedora/linux/planetccrma/10/i386/planetccrma-repo-1.1-2.fc10.ccrma.noarch.rpm

2、jpackage
http://www.jpackage.org/
下載.repo文件,保存到/etc/yum.repos.d/ 下。http://www.jpackage.org/jpackage17.repo

3、RPM Fusion
http://rpmfusion.org/
rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -ivh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

4、ATrpms
http://atrpms.net/

5、rpm.livna.org(已經合併)
http://rpm.livna.org/

6、freshrpms(已經合併)
http://freshrpms.net

7、rpmfind(法國東部的一個城市)
http://www.rpmfind.net/
安裝
ftp://rpmfind.net/pub/rpmfind/

8、RPM.pbone.net
http://rpm.pbone.net/
一個付費的yum repository。可以註冊一個用戶,免費試用14天,依照自己的需求配置不同的.repo文件。
比如:

This is experimental system. Use it on own risk.
Copy below section and put it into /etc/yum.repos.d/pbone.repo file.
[65i386]
name=PBONE Fedora 10 i386
baseurl=http://yum.pbone.net/65/i386/
gpgcheck=0
proxy=http://proxy.pbone.net:3127/
proxy_username=marco
proxy_password=123456789
[65noarch]
name=PBONE Fedora 10 noarch
baseurl=http://yum.pbone.net/65/noarch/
gpgcheck=0
proxy=http://proxy.pbone.net:3127/
proxy_username=marco
proxy_password=123456789

此文獻給在爲yum默默淚崩的fedora fans,希望以上對fedora fans有所幫助。

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