首先了解各自的镜像是哪个版本
对于rhel7
#挂载光驱到系统目录[root@rh7-node1 ~]# mkdir /rhel7.9
[root@rh7-node1 ~]# mount /dev/cdrom /rhel7.9/
mount: /dev/sr0 is write-protected, mounting read-only#设置光驱开机自动挂载[root@rh7-node1 ~]# vim /etc/rc.d/rc.local #开机自运行脚本
touch /var/lock/subsys/local
mount /dev/cdrom /rhel7.9
[root@rh7-node1 ~]# chmod +x /etc/rc.d/rc.local #配置仓库指向文件[root@rh7-node1 ~]# cd /etc/yum.repos.d/
[root@rh7-node1 yum.repos.d]# vim rhel7.repo
[rhel7]
name = rhel7
baseurl = file:///rhel7.9
gpgcheck=0


对于rhel9
#挂载光驱到系统目录[root@rh9-node1 ~]# mkdir /rhel9.2
[root@rh9-node1 ~]# mount /dev/cdrom /rhel9.2/
mount: /dev/sr0 is write-protected, mounting read-only#设置光驱开机自动挂载[root@rh9-node1 ~]# vim /etc/rc.d/rc.local
touch /var/lock/subsys/local
mount /dev/cdrom /rhel9.2/
[root@rh9-node1 ~]# chmod +x /etc/rc.d/rc.local #配置仓库指向文件[root@rh9-node1 ~]# cd /etc/yum.repos.d/
[root@rh9-node1 yum.repos.d]# vim rhel9.repo[AppStream]
name=AppStream
baseurl=file:///rhel9.2/AppStream
gpgcheck=1
gpgkey=file:///rhel9.2/RPM-GPG-KEY-redhat-release
enabled=1[BaseOS]
name=BaseOS
baseurl=file:///rhel9.2/BaseOS
gpgcheck=1
gpgkey=file:///rhel9.2/RPM-GPG-KEY-redhat-release
enabled=1
