centos yum源問題

來源:互聯網
上載者:User

標籤:

 在配置CentOS-6.0-x86_64-bin-DVD2.iso作為本地yum源的時候,碰到相當多的問題:

-----------------------------------------  問題一  ------------------------------------------

將CentOS-6.0-x86_64-bin-DVD2.iso掛載在/mnt上,並配置本地yum源:

  1. #mount /root/CentOS-6.0-x86_64-bin-DVD2.iso /mnt -o loop 
  2. #vi /etc/yum.repos.d/software.repo 
  3.  [software] 
  4.  name=software 
  5.  baseurl=file:///mnt 
  6.  enabled=1 
  7.  gpgcheck=1 
  8.  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 
  9. #yum repolist 

然後就報錯了-_-!,錯誤的資訊差不多就是:

file:///mnt/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/repodata/repomd.xml . mistake from baseurl does not contain the repodata directory

問題出現的原因:

CentOS-6.0-x86_64-bin-DVD2.iso這個鏡像裡沒有包含yum的包索引資料庫repomd.xml,這個檔案一般是放在repodata檔案夾的。所以,不用特殊的工具,這個CentOS-6.0-x86_64-bin-DVD2.iso中包含的Packages不能單獨作為yum的本地源。

-----------------------------------------  問題二  ------------------------------------------

在我的CentOS-6中,/etc/yum.repos.d/目錄下本身已經有3個已經建好的repo庫了,是Base、Media、Debug。

我自己建立一個software.repo,使用CentOS-6.0-x86_64-bin-DVD1.iso這個鏡像,這個鏡像中包含repodata檔案。

但不管我怎麼調整設定,用yum repolist命令都搜不到iso中包含的軟體包,並且將所有的.repo中的enabled值都設定為1,但使用yum repolist會提示錯誤:

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=centosplus error was 14:PYCURL ERROR 6 - "Couldn‘t resolve host ‘mirrorlist.centos.org‘"Error: Cannot retrieve repository metadata (repomd.xml) for repository: centosplus. Please verify its path and try again

解決方案:要使用自己建立的yum本地源,需要將系統本身提供的.repo庫暫時設定為禁用(enabled=0),這樣的情況下,使用yum repolist就可以正確的搜尋iso提供的本地軟體包庫了。

附:建立本地yum源的步驟:

1、將帶有軟體包和相應repodata索引的iso鏡像掛載在某目錄下(我是放在/mnt下)

2、在/etc/yum.repos.d/下建立自己的設定檔(例如software.repo),必須用.repo結尾,內容為:

  1. [software]                     //software是配置名 
  2. name=software 
  3. baseurl=file:///mnt/           //因為是本地源,所以是file://,指向軟體庫和repodata的父目錄 
  4. enabled=1                      //啟用這個配置 
  5. gpgcheck=0                     //不進行gpg檢查 

3、將yum.repos.d/目錄下得其他設定檔的enabled索引值設定為0,否則按順序執行時會干擾自己建立的設定檔。

centos yum源問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.