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观察情况

相关内容