yum的配置文件yum.conf詳解


說明:經過網上抄襲和自己的總結加實驗,非常詳細,可留作參考。

yum的配置一般有兩種方式:   一種是直接配置/etc目錄下的yum.conf文件, 另外一種是在/etc/yum.repos.d目錄下增加.repo文件。 
一、yum的配置文件yum.conf詳解   

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

二、*.repo文件詳解   什么是repo文件? repo文件是Fedora中yum源(軟件倉庫)的配置文件,通常一個repo文件定義了一個或者多個軟件倉庫的細節內容,例如我們將從哪里下載需要安裝或者升級的軟件包,repo文件中的設置內容將被yum讀取和應用!
我們以一份系統自帶的repo文件做為實例來探討(Fedora和redhat是一致的)(#號后面是我加的注釋):

01. [fedora]       #方括號里面的是軟件源的名稱,將被yum取得並識別
02.  
03. name=Fedora $releasever - $basearch   #這里也定義了軟件 倉庫的名稱,通常是為了方便閱讀配置文件,一般沒什么作用,$releasever變量定義了發行版本,通常是8910等數字,$basearch變 量定義了系統的架構,可以是i386、x86_64、ppc等值,這兩個變量根據當前系統的版本架構不同而有不同的取值,這可以方便yum升級的時候選擇 適合當前系統的軟件包,以下同……
04. failovermethod=priority   #failovermethod 有兩個值可以選擇,priority是默認值,表示從列出的baseurl中順序選擇鏡像服務器地址,roundrobin表示在列出的服務器中隨機選擇
05. exclude=compiz* *compiz* fusion-icon* #exclude這個選項是后來我自己加上去的,用來禁止這個軟件倉庫中的某些軟件包的安裝和更新,可以使用通配符,並以空格分隔,可以視情況需要自行添加
06. #baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
07. #上面的一行baseurl第一個字符是'#'表示該行已經被注釋,將不會被讀取,這一行的意思是指定一個baseurl(源的鏡像服務器地址)
08. #mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
09. #上面的這一行是指定一個鏡像服務器的地址列表,通常是開啟的,本例中加了注釋符號禁用了,我們可以試試,將$releasever和$basearch替換成自己對應的版本和架構,例如10和i386,在<a href="http://www.it165.net/edu/ewl/" target="_blank" class="keylink">瀏覽器</a>中打開,我們就能看到一長串鏡可用的鏡像服務器地址列表。
10. 選擇自己訪問速度較快的鏡像服務器地址復制並粘貼到repo文件中,我們就能獲得較快的更新速度了,格式如下baseurl所示:
11. baseurl=
12. ftp://ftp.sfc.wide.ad.jp/pub/<a href="http://www.it165.net/os/oslin/" target="_blank" class="keylink">Linux</a>/Fedora/releases/10/Everything/i386/os
13. http://ftp.chg.ru/pub/<a href="http://www.it165.net/os/oslin/" target="_blank" class="keylink">Linux</a>/fedora/linux/releases/10/Everything/i386/os
14. http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/releases/10/Everything/i386/os
15. http://mirror.nus.edu.sg/fedora/releases/10/Everything/i386/os
16. http://mirror.yandex.ru/fedora/linux/releases/10/Everything/i386/os
17. http://ftp.twaren.net/Linux/Fedora/linux/releases/10/Everything/i386/os
18. http://ftp.itu.edu.tr/Mirror/Fedora/linux/releases/10/Everything/i386/os
19.  
20. enabled=1 #這個選項表示這個repo中定義的源是啟用的,0為禁用
21. gpgcheck=1 #這個選項表示這個repo中下載的rpm將進行gpg的校驗,已確定rpm包的來源是有效和安全的
22. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch #定義用於校驗的gpg密鑰,就是數位簽章的公鑰檔所在位置!
23.  
24. ##以下的軟件倉庫基本上用不到,選項含義同上
25. [fedora-debuginfo]
26. name=Fedora $releasever - $basearch - Debug
27. failovermethod=priority
28. #baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/
29. mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-debug-$releasever&arch=$basearch
30. enabled=0
31. gpgcheck=1
32. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch
33.  
34. [fedora-source]
35. name=Fedora $releasever - Source
36. failovermethod=priority
37. #baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/source/SRPMS/
38. mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-source-$releasever&arch=$basearch
39. enabled=0
40. gpgcheck=1
41. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch

下面看看rhel5.8自帶的repo文件  

1. [root@10gasm yum.repos.d]# cat rhel-debuginfo.repo
2. [rhel-debuginfo]
3. name=Red Hat Enterprise Linux $releasever - $basearch - Debug
4. baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
5. enabled=0
6. gpgcheck=1
7. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

我自己設置的本地yum庫

1. [root@10gasm yum.repos.d]# cat dvd.repo
2. [dvd]
3. name=install dvd
4. baseurl=file:///mnt/Server
5. enabled=1
6. gpgcheck=0

非常簡單。   可以使用下面的命令查看所有的容器配置(Repository)是否生效

1. yum repolist all

使用all參數列出了所有的容器配置,如果不加all只列出可用的Repository,這個可用性取決於repo配置文件中的enabled參數,如果為0,則不可用,為1則可用 例如:

1. [root@10gasm yum.repos.d]# yum repolist all
2. Loaded plugins: katello, product-id, security, subscription-manager
3. Updating certificate-based repositories.
4. Unable to read consumer identity
5. repo id                                           repo name                                                                       status
6. dvd                                               install dvd                                                                     <strong>enabled:3,285</strong>
7. rhel-debuginfo                                    Red Hat Enterprise Linux 5Server - x86_64 - Debug                               <strong>disabled</strong>
8. repolist: 3,285

 顯示出dvd這個repository是可用的,有3285個文件,rhel-debuginfo這個庫是不可用的。

如果修改rhel-debuginfo中enabled為1然后再次查看

01. [root@10gasm yum.repos.d]# yum repolist all
02. Loaded plugins: katello, product-id, security, subscription-manager
03. Updating certificate-based repositories.
04. Unable to read consumer identity
05. ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/x86_64/Debuginfo/repodata/repomd.xml: [Errno 4] IOError: <urlopen error (-3, 'Temporary failure in name resolution')>
06. Trying other mirror.
07. repo id                                           repo name                                                                      status
08. dvd                                               install dvd                                                                    enabled: 3,285
09. rhel-debuginfo                                    Red Hat Enterprise Linux 5Server - x86_64 - Debug                              <strong>enabled:     0</strong>
10. repolist: 3,285<br>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM