Solution to [errno 5] oserror: [errno 2] on RedHat server

Time:2020-12-18

When configuring the local source of Yum on Red Hat Enterprise Linux server release 5.7, we encountered “[errno 5] oserror: [errno 2] no such file or directory XXX”. It took some time to figure out the cause and effect of the error. It is hereby recorded that:

Copy the image of RedHat 5.7 to / MNT / CDROM / linuxsrc, and configure RHEL- media.repo File, as shown below
 

Copy code

The code is as follows:

[[email protected] 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

 
After executing the yum clean all command, the following error occurred when executing Yum makecache:
 

Copy code

The code is as follows:

[[email protected] yum.repos.d]# yum clean all
Loaded plugins: product-id, security, subscription-manager
Updating Red Hat repositories.
Cleaning up Everything
[[email protected] 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
[[email protected] yum.repos.d]#


The root cause of this error is that the RPM package storage paths of RHEL 5. X and RHEL 6. X are different

RHEL 5. X… / server for example: my case environment is located under / MNT / CDROM / linuxsrc / server.

RHEL 6.x : ../Packages

Therefore, the baseurl parameter above is set incorrectly. Then we can solve this problem in two ways

 

Method 1: configure the correct baseurl parameter.
 

Copy code

The code is as follows:

[[email protected] 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

Method 2: create a local source directory by using the createepo command and point it to the directory specified by baseurl

Copy code

The code is as follows:

[[email protected] 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%]
[[email protected] Server]# createrepo –update /mnt/cdrom/LinuxSrc
Previous repo file missing: /mnt/cdrom/LinuxSrc/repodata/primary.xml.gz3388/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
[[email protected] Server]# yum makecacheLoaded 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[[email protected] Server]#

Recommended Today

A very lightweight MySQL operation framework is recommended

A very lightweight MySQL operation framework is recommended:Portal Default support function method explain boolean has(Serializable id) Check whether the record exists according to the primary key E findById(Serializable id) Find objects by primary key List<E> findByIds(Collection<? extends Serializable> ids) Find objects in batch based on primary key List<E> find() Query all records List<E> findByColumn(String column, […]