1.先将ios挂载
[root@yuanqu resource]# mkdir -p /mnt/cdrom
[root@yuanqu resource]# mount -o loop CentOS-7.8-x86_64-DVD-2003.iso /mnt/cdrom
mount: /dev/loop0 is write-protected, mounting read-only
[root@yuanqu resource]# ll /mnt/cdrom
total 694
-rw-rw-r--. 2 root root 14 Apr 20 2020 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Apr 20 2020 EFI
-rw-rw-r--. 3 root root 227 Aug 30 2017 EULA
-rw-rw-r--. 3 root root 18009 Dec 9 2015 GPL
drwxr-xr-x. 3 root root 2048 Apr 20 2020 images
drwxr-xr-x. 2 root root 2048 Apr 20 2020 isolinux
drwxr-xr-x. 2 root root 2048 Apr 20 2020 LiveOS
drwxr-xr-x. 2 root root 671744 Apr 21 2020 Packages
drwxrwxr-x. 2 root root 4096 Apr 21 2020 repodata
-rw-rw-r--. 3 root root 1690 Dec 9 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 3 root root 1690 Dec 9 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Apr 21 2020 TRANS.TBL
2.修改网络yum源,改为本地yum源
[root@yuanqu yum.repos.d]# cat CentOS-Media.repo
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///mnt/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=1 #是否启用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
3.清除缓存
# yum clean all
# yum list
3.测试一下能不能用
[root@yuanqu yum.repos.d]# yum -y install unixODBC
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* c5-media:
Resolving Dependencies
--> Running transaction check
---> Package unixODBC.x86_64 0:2.3.1-14.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================
Installing:
unixODBC x86_64 2.3.1-14.el7 c5-media 413 k
Transaction Summary
===============================================================================================================================
Install 1 Package
Total download size: 413 k
Installed size: 1.2 M
Downloading packages:
warning: /mnt/cdrom/Packages/unixODBC-2.3.1-14.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for unixODBC-2.3.1-14.el7.x86_64.rpm is not installed
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-8.2003.0.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : unixODBC-2.3.1-14.el7.x86_64 1/1
Verifying : unixODBC-2.3.1-14.el7.x86_64 1/1
Installed:
unixODBC.x86_64 0:2.3.1-14.el7
Complete!