在Red Hat Enterprise Linux Server release 5.7 上配置YUM本地源时,遇到了"Errno 5] OSError: [Errno 2] No such file or directory xxxx",花了点时间搞清楚错误的来龙去脉。特此记录一下:

将Redhat 5.7的光盘镜像拷贝到了/mnt/cdrom/LinuxSrc目录下,配置了rhel-media.repo文件,如下所示

[root@DB-Server yum.repos.d]# more rhel-media.repo 

[media]

name=Red Hat Enterprise Linux 5.7                                

baseurl=file:///mnt/cdrom/LinuxSrc                                         

enabled=1                                                         

gpgcheck=0                                                        

gpgkey=file:///mnt/cdrom/LinuxSrc/RPM-GPG-KEY-redhat-release 

执行yum clean all命令后,执行yum makecache遇到了下面错误:

[root@DB-Server yum.repos.d]# yum clean all

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

Cleaning up Everything

[root@DB-Server yum.repos.d]# yum makecache

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

file:///mnt/cdrom/LinuxSrc/repodata/repomd.xml: [Errno 5] OSError: [Errno 2] No such file or directory: '/mnt/cdrom/LinuxSrc/repodata/repomd.xml'

Trying other mirror.

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

[root@DB-Server yum.repos.d]# 

出现这个错误的根本原因在于RHEL 5.x 版本与RHEL 6.x 版本的rpm包存放路径不同:

RHEL 5.x : ../Server    例如:我案例环境位于/mnt/cdrom/LinuxSrc/Server 下。

RHEL 6.x : ../Packages

所以还在于上面的baseurl参数设置错误。那么我们可以通过两种方法解决这个问题:

 

方法1:配置正确的baseurl参数。

[root@DB-Server yum.repos.d]# vi rhel-media.repo 

[media]

name=Red Hat Enterprise Linux 5.7

baseurl=file:///mnt/cdrom/LinuxSrc/Server

enabled=1

gpgcheck=0

gpgkey=file:///mnt/cdrom/LinuxSrc/RPM-GPG-KEY-redhat-release

 

方法2:使用createrepo命令创建本地源目录,将其指向baseurl指定的目录

[root@DB-Server Server]# rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm

warning: createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing...                ########################################### [100%]

   1:createrepo             ########################################### [100%]

[root@DB-Server Server]# createrepo --update /mnt/cdrom/LinuxSrc

Previous repo file missing: /mnt/cdrom/LinuxSrc/repodata/primary.xml.gz

3388/3388 - VT/etherboot-roms-5.4.4-15.el5.x86_64.rpm                           mm

Saving Primary metadata

Saving file lists metadata

Saving other metadata

You have new mail in /var/spool/mail/root

[root@DB-Server Server]# yum makecache

Loaded plugins: product-id, security, subscription-manager

Updating Red Hat repositories.

media                    |  951 B     00:00     

media/filelists          | 3.1 MB     00:00     

media/other              |  11 MB     00:00     

media/primary            | 1.1 MB     00:00     

media                                 3388/3388

media                                 3388/3388

media                                 3388/3388

Metadata Cache Created

[root@DB-Server Server]# 

RHEL 5.7 Yum配置本地源[Errno 2] No such file or directory的更多相关文章

  1. centos 系统软件包管理 yum 本地yum配置 扩展源epel rpm 清除yum缓存 yum provides "*/vim" 第十节课

    centos  系统软件包管理  yum 本地yum配置  扩展源epel  rpm  清除yum缓存  yum provides "*/vim"   第十节课 你不能保证可逆化操 ...

  2. Ubuntu 配置本地源

    Ubuntu 配置本地源 操作系统 Ubuntu 20.04.2 LTS 一.挂载 iso 到本地 mount -t iso9660 -o loop /dev/sr0 /media/cdrom //- ...

  3. Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt

    最近安装python,已经安装好,cmd终端中输入python.pip等命令都有用 然而在配置requirements.txt文件过程中,执行语句 “pip install -r requiremen ...

  4. FileNotFoundError: [Errno 2] No such file or directory: 'image/1.jpg'问题解决

    FileNotFoundError: [Errno 2] No such file or directory: 'image/1.jpg'问题 最近在学习爬虫,想爬一些图片并保存到本地,但是在下载图片 ...

  5. VSCode python 遇到的问题:vscode can't open file '<unprintable file name>': [Errno 2] No such file or directory

    代码很简单,就两行: import pandas as pd import netCDF4 as nc dataset = nc.Dataset('20150101.nc') 环境:在VSCode中左 ...

  6. can't open file 'manage.py': [Errno 2] No such file or directory

    python Django创建数据库时can't open file 'manage.py': [Errno 2] No such file or directory 参考https://blog.c ...

  7. ansible执行shell模块和command模块报错| FAILED | rc=127 >> /bin/sh: lsof: command not found和| rc=2 >> [Errno 2] No such file or directory

    命令: ansible -i hosts_20 st  -m shell -a 'service zabbix_agentd star'  -K --become ansible -i hosts_2 ...

  8. [Errno 2] No such file or directory

    Centos7.5 执行ansible命令报错 问题: [root@m01 ~]# ansible servers -a "hostname|grep web" -i ./host ...

  9. 关于python中的 “ FileNotFoundError: [Errno 2] No such file or directory: '……'问题 ”

    今天在学python时,在模仿一个为图片加上图标并移动到指定文件夹的程序时遇到“FileNotFoundError: [Errno 2] No such file or directory: '152 ...

随机推荐

  1. iOS 如何设置导航的滑动返回手势, 和系统饿一样

    iOS 7 滑动返回那些事儿 2014/05/17 Wei .entry-meta .entry-header 在智能机越来越普及,屏幕越做越大的当下,滑动返回手势已经成为了一个应用的标配功能,甚至可 ...

  2. iOS-LaunchImage启动页

    一. 目标: 设置一个漂亮的启动页. 二.步骤 1. 先创建LaunchImage 2. 进一步设置需要适配的启动页机型 3. 设置完成的效果 4.往里面拖图片,如图是适配的图片的配置 5. 在项目中 ...

  3. 初识openstack

    <1>虚拟化技术的功能和特点 多个虚拟机运行在一台物理服务器上,虚拟机之间共享物理资源,虚拟机可以分别安装不同的操作系统,应用程序相互隔离. 虚拟化技术的优势:虚拟机的操作系统和应用程序不 ...

  4. C# 将内容写入txt文档

    <1>  FileStream fs = new FileStream(@"D:\text.txt", FileMode.Append); StreamWriter s ...

  5. ztree + ashx +DataTable +Oracle

    问题描述 好久没有使用ztree了,刚才在使用ztree做导航时遇到了几个小问题: 1.返回数据源是undefined . 2.数据出现后树结构没有出现(pIdKey单词拼写错误). 3.在使用Ora ...

  6. JS实现动态显示当前时间

    效果图: 代码实现: <script language="JavaScript"> var timerID = null; var timerRunning = fal ...

  7. 3分钟干货学会使用node-inspector调试NodeJS代码

    使用node-inspector调试NodeJS代码 任何一门完备的语言技术栈都少不了健壮的调试工具,对于NodeJS平台同样如此,笔者研究了几种调试NodeJS代码的方式,通过对比,还是觉得node ...

  8. Django 1.10 中文文档------3.2.2 查询操作making queries

    3.2.2 查询操作 6.15章节包含所有模型相关的API解释. 后面的内容基于如下的一个博客应用模型: from django.db import models class Blog(models. ...

  9. Ionic2学习笔记(10):扫描二维码

    作者:Grey 原文地址: http://www.cnblogs.com/greyzeng/p/5575843.html 时间:6/11/2016     说明: 在本文发表的时候(2016-06-1 ...

  10. .NET Task揭秘(一)

    Task为.NET提供了基于任务的异步模式,它不是线程,它运行在线程池的线程上.本着开源的精神, 本文以解读基于.NET4.5 Task源码的方式来揭秘Task的实现原理.   Task的创建 Tas ...