天天看点

linux中本地yum报错:file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdro

linux中本地yum报错:file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdrom/repodata/repomd.xml

Trying other mirror.

Error: Cannot retrieve repository metadata (repomd.xml) for repository: local. Please verify its path and try again

  1. 先find /mnt/ -name repomd.xml看看是file:///mnt/cdrom/repodata/repomd.xml的路径一致,基本都是不一致的。
[[email protected] etc]# yum list
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdrom/repodata/repomd.xml
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: local. Please verify its path and try again
[[email protected] etc]# find /mnt/ -name repomd.xml
/mnt/iso/repodata/repomd.xml
           

2.在这种情况下我们需要进入cd /etc/yum.conf文件夹中修改一下文件夹的路径。从而使得文件夹路径一致。代码截图示意如下:

linux中本地yum报错:file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdro
vi /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[local]
name=file
baseurl=file:///mnt/cdrom
gpgcheck=0
           

3.将上述中的baseurl=file:///mnt/cdrom换成find /mnt/ -name repomd.xml找到的路径,代码如下:

[local]
name=file
baseurl=file:///mnt/iso
gpgcheck=0
           

4.接下来我们保存更新yum源后即可,代码如下:

[[email protected] etc]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: c6-media local
Cleaning up Everything
Cleaning up list of fastest mirrors
[[email protected] etc]# yum update
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
c6-media                                                                                                                                                              | 4.0 kB     00:00 ... 
c6-media/primary_db                                                                                                                                                   | 4.4 MB     00:00 ... 
local                                                                                                                                                                 | 4.0 kB     00:00 ... 
local/primary_db                                                                                                                                                      | 4.4 MB     00:00 ... 
Setting up Update Process
No Packages marked for Update
           

5.我这个只是挂载一个盘的情况下,如果你是挂载两个盘顺序出错导致,建议你看一下这个博主的。yum设置为本地源的时候,发现使用yum命令竟然报错