我們以一份系統自帶的repo文件做為實例來探討(Fedora和redhat是一致的)(#號后面是我加的注釋):

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

 

 

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

 

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

我自己設置的本地yum庫

[root@10gasm yum.repos.d]# cat dvd.repo 
[dvd]
name=install dvd
baseurl=file:///mnt/Serverenabled=1gpgcheck=0

非常簡單。

 

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

yum repolist all

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

例如:

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

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

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

[root@10gasm yum.repos.d]# yum repolist all
Loaded plugins: katello, product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identityftp://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')>Trying other mirror.
repo id                                           repo name                                                                      status
dvd                                               install dvd                                                                    enabled: 3,285rhel-debuginfo                                    Red Hat Enterprise Linux 5Server - x86_64 - Debug                              enabled:     0repolist: 3,285







配置好以后,執行yum update,報錯:Error performing checksum

 

[root@web1 yum.repos.d]# yum update

Loaded plugins: katello, product-id,security, subscription-manager

Updating certificate-based repositories.

Unable to read consumer identity

base                                                                                                        | 3.7 kB     00:00    

base/primary_db                                                                                              |4.4 MB     00:02    

http://mirrors.ustc.edu.cn/centos/6.4/os/x86_64/repodata/1e584feac3f3fb76ad4b6fb7e1bc8d44fa124814e9d186dc913ded3c63a216b3-primary.sqlite.bz2:

[Errno -3] 

Error performingchecksum

Trying other mirror.

base/primary_db                                                                                             | 4.4 MB     00:02    

http://mirrors.ustc.edu.cn/centos/6.4/os/x86_64/repodata/1e584feac3f3fb76ad4b6fb7e1bc8d44fa124814e9d186dc913ded3c63a216b3-primary.sqlite.bz2:

[Errno -3] Error performing checksum

Trying other mirror.

Error: failure:repodata/1e584feac3f3fb76ad4b6fb7e1bc8d44fa124814e9d186dc913ded3c63a216b3-primary.sqlite.bz2from base: [Errno 256] No more mirrors to try.

 

 

google了一下,說是在rhel 6 中 repomd.xml 文件使用 sha256 作為hash 

算法

 ,在rhel 5中 默認使用的是sha 作為hash 算法。

 

但我是在redhat 5.8 上使用5.9的yum。 也出現了這種錯誤。

# yum clean all 清空yum的注冊記錄.

更多關于云服務器域名注冊,虛擬主機的問題,請訪問三五互聯官網:m.shinetop.cn

贊(0)
聲明:本網站發布的內容(圖片、視頻和文字)以原創、轉載和分享網絡內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。郵箱:3140448839@qq.com。本站原創內容未經允許不得轉載,或轉載時需注明出處:三五互聯知識庫 » 配置YUM源的步驟(原理)

登錄

找回密碼

注冊