歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 6配置本地yum源時遇到的問題及解決

CentOS 6配置本地yum源時遇到的問題及解決

日期:2017/2/28 16:05:47   编辑:Linux教程
在配置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,否則按順序執行時會干擾自己建立的配置文件。

Copyright © Linux教程網 All Rights Reserved