標籤:
在配置CentOS-6.0-x86_64-bin-DVD2.iso作為本地yum源的時候,碰到相當多的問題:
----------------------------------------- 問題一 ------------------------------------------
將CentOS-6.0-x86_64-bin-DVD2.iso掛載在/mnt上,並配置本地yum源:
- #mount /root/CentOS-6.0-x86_64-bin-DVD2.iso /mnt -o loop
- #vi /etc/yum.repos.d/software.repo
- [software]
- name=software
- baseurl=file:///mnt
- enabled=1
- gpgcheck=1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
- #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結尾,內容為:
- [software] //software是配置名
- name=software
- baseurl=file:///mnt/ //因為是本地源,所以是file://,指向軟體庫和repodata的父目錄
- enabled=1 //啟用這個配置
- gpgcheck=0 //不進行gpg檢查
3、將yum.repos.d/目錄下得其他設定檔的enabled索引值設定為0,否則按順序執行時會干擾自己建立的設定檔。
centos yum源問題