Linux yum出錯 Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again,

來源:互聯網
上載者:User

Linux yum出錯 Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again,

Linux下使用yum命令時報錯Error: Cannot retrieve repository metadata (repomd.xml) for repository......,具體如下所示

 [root@localhost yum.repos.d]# yum makecache
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository base is listed more than once in the configuration
file:///media/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/repodata/repomd.xml
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
[root@localhost yum.repos.d]# ls /media -hl
total 3633166
dr-x------.  1 root root 8.0k Sep 14 20:32 CDROM
dr-xr-xr-x. 12 root root 8.0k Jan 30  2013 RHEL_6.4 x86_64 Disc 1
-rwxr-xr-x.  1 root root 3.5G Dec 16  2015 rhel-server-6.4-x86_64-dvd.iso

請注意觀察錯誤資訊,在Error上有提示:

file:///media/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/repodata/repomd.xml

意思是說repomd檔案沒有找到,這會導致yum命令無法檢索存放庫中繼資料(翻譯的,或者理解為找不到庫);即需要讓yum命令能找到這個檔案,這個檔案預設在系統安裝光碟片的/repodata/目錄下;

檢查yum配置資訊,到/etc/yum.repos.d/下檢查配置的repo檔案:

[root@localhost /]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls -l
total 8
drwxr-xr-x. 2 root root 4096 Oct 11 02:04 bak_repo
-rwxr-xr-x. 1 root root  162 Oct 11 01:36 rhel-base.repo
[root@localhost yum.repos.d]# more rhel-base.repo
[base]
name=RedHat
baseurl=file:///media/
enabled=1
gpgcheck=0
gpgkey=file:///media/RPM-GPG-KEY-redhat-release

這裡關係到如何配置本地yum源,對於如何配置yum源,可以參考:

http://www.cnblogs.com/Wherebolezi/p/4626670.html

在本地yum設定檔上,可以看到yum指向本地的/media/檔案;/media目錄如下

[root@localhost yum.repos.d]# ls /media -hl
total 3.5G
dr-x------.  1 root root 2.0K Sep 14 20:32 CDROM
dr-xr-xr-x. 12 root root 8.0K Jan 30  2013 RHEL_6.4 x86_64 Disc 1
-rwxr-xr-x.  1 root root 3.5G Dec 16  2015 rhel-server-6.4-x86_64-dvd.iso

通過以上資訊,表示/media目錄下不存在repomd.xml檔案,這個檔案在RHEL_6.4 x86_64 Disc 1中;可以通過修改yum配置讓系統能找到檔案

修改後的內容如下(注意目錄中的空格前需要\轉義符):

[base]
name=RedHat
baseurl=file:///media/RHEL_6.4\ x86_64\ Disc\ 1
enabled=1
gpgcheck=0
gpgkey=file:///media/RHEL_6.4\ x86_64\ Disc\ 1/RPM-GPG-KEY-redhat-release

然後清理: yum clean all

yum makecache

結果如下所示:

[root@localhost yum.repos.d]# yum clean all
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: base
Cleaning up Everything
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base                                                                                                                                                                       | 3.9 kB     00:00 ...
base/group_gz                                                                                                                                                              | 204 kB     00:00 ...
base/filelists_db                                                                                                                                                          | 3.7 MB     00:00 ...
base/primary_db                                                                                                                                                            | 3.1 MB     00:00 ...
base/other_db                                                                                                                                                              | 1.5 MB     00:00 ...
Metadata Cache Created

沒有 Error: Cannot retrieve.....內容,且沒有Could not open/read file......等打不開檔案的提示,即表示問題已解決

如果問題仍然存在,則需要核對下安裝光碟片與系統本身是否匹配,或者yum源與系統版本的匹配程度,然後多執行幾次yum clean all --> yum makecache觀察情況

相關文章

聯繫我們

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