配置 RHEL 使用本地源(光盘)

创建目录,并将 RHEL 光盘内容复制到该目录中;

[it@pxesvr ~]$ sudo mkdir /os
[sudo] password for it: 
[it@pxesvr ~]$ sudo cp -r /run/media/it/RHEL-8-0-0-BaseOS-x86_64/* /os/

配置 yum 源配置文件,更改 baseurl,指定到刚刚创建的目录中的 BaseOS 和 AppStrem;

[it@pxesvr ~]$ sudo vim /etc/yum.repos.d/redhat.repo
[it@pxesvr ~]$ grep -v ^# /etc/yum.repos.d/redhat.repo
[localREPO]
name=localhost8
baseurl=file:///os/BaseOS
enable=1
gpgcheck=0

[localREPO_APP]
name=localhost8_app
baseurl=file:///os/AppStream
enable=1
gpgcheck=0

清除存储库中的所有临时文件,然后下载并缓存所有已知的存储库。

[it@pxesvr ~]$ sudo yum clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
0 files removed
[it@pxesvr ~]$ sudo yum makecache 
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
localhost8                                                                       25 MB/s | 2.2 MB     00:00    
localhost8_app                                                                   54 MB/s | 5.3 MB     00:00    
Metadata cache created.

测试(可以查询库中可用的软件包)

[it@pxesvr ~]$ yum list bind
Not root, Subscription Management repositories not updated
Last metadata expiration check: 5:53:29 ago on Mon 12 Oct 2020 11:04:43 AM CST.
Available Packages
bind.x86_64                                  32:9.11.4-16.P2.el8                                   localREPO_APP