背景:
在产品不断更新迭代的过程中,需要满足日渐繁多的客户基础设施需求,即覆盖更多的兼容性测试,
但是在公司环境下一般是给定的系统模板、不能连通外网,此时为了满足需求,需要手动的使用本地镜像进行低版本升级到高版本
实操举例:
本地虚机机镜像rhel8.0,升级到rhel8.4版本
步骤:
通过官方网站注册账号,进行指定版本下载镜像
镜像地址:https://developers.redhat.com/rhel8
![](https://img-blog.csdnimg.cn/img_convert/7129c40a005ea088532eb3f8542f937f.png)
上传至linux服务器
![](https://img-blog.csdnimg.cn/img_convert/c882155b0b5bf5621e2a3e618d1b758b.png)
创建挂载目录
mkdir -p /mnt/iso_dir
mount -o loop rhel-8.4-x86_64-dvd.iso /mnt/iso_dir
![](https://img-blog.csdnimg.cn/img_convert/61667b0ffa7e6d441b0a07b6d7ec0d42.png)
![](https://img-blog.csdnimg.cn/img_convert/cef12108859bb0f16d55dfcd7610b961.png)
检查挂载目录下.discinfo文件中的数值
head -n1 mnt/iso_dir/.discinfo
将media.repo文件从安装目录到/etc/yum.repos.d/
cp -v /mnt/iso_dir/media.repo /etc/yum.repos.d/rhel8.4.repo
chmod 644 /etc/yum.repos.d/rhel8.4.repo
![](https://img-blog.csdnimg.cn/img_convert/7e703ce8e560c8842444c0d051c647d8.png)
在“ /etc/yum.repos.d/rhel8.4.repo”文件中添加存储库条目
编辑rhel8.4.repo文件并添加以下内容
[InstallMedia]
name=Red Hat Enterprise Linux 8.4.0
mediaid=1656659703.292617 #挂载目录下.discinfo文件中的数值
metadata_expire=-1
gpgcheck=1
cost=500
enabled=1
baseurl=file:///mnt/iso_dir//BaseOS/ #其中mnt/iso_dir/为镜像挂载路径
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[InstallMedia-AppStream]
name=Red Hat Enterprise Linux 8.4.0 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///mnt/iso_dir/AppStream/ #其中mnt/iso_dir/为镜像挂载路径
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
![](https://img-blog.csdnimg.cn/img_convert/ee0244fe50a3c2e99d8a9ec67d99216b.png)
切换repo
wget -O /etc/yum.repos.d/iso.repo rhel8.4.repo
curl -o /etc/yum.repos.d/iso.repo rhel8.4.repo
![](https://img-blog.csdnimg.cn/img_convert/83319d7d7393d3c0733dcfc65db28bf4.png)
清理Yum / DNF和Subscription Manager缓存
dnf clean all
subscription-manager clean
验证Yum / DNF是否正在从本地仓库获取软件包
dnf repolist
![](https://img-blog.csdnimg.cn/img_convert/47749f22ad9cd32e14b5ffda023acd2d.png)
使用Yum进行升级
yum update
![](https://img-blog.csdnimg.cn/img_convert/aa93fc3c7f6f7cc4d9751fd35dbd34c0.png)