在离线环境中将 CentOS 7.x 原地迁移至 RHEL 7.9
本文最后更新于 397 天前,其中的信息可能已经有所发展或是发生改变。

在离线环境中将 CentOS 7.x 原地迁移至 RHEL 7.9

说明

CentOS 7.x 需要先更新到 CentOS 7.9 后才能迁移到 RHEL 7.9,另外出于方便,以下所有操作都使用的是 root 用户

Red Hat Enterprise Linux (RHEL) 7.9的生命周期如下:

  • 发布日期: 2019年9月10日
  • 标准支持期: 2019年9月10日 – 2024年6月30日
  • 延长生命周期支持(ELS): 2024年7月1日 – 2026年6月30日

Convert2RHEL 简介

Convert2RHEL 是 RedHat 提供的一个命令行工具,用于分析系操作统的情况,并将基于 RPM 的 Linux 操作系统转换为红帽企业 Linux。 它支持将 CentOS Linux 7 和 Oracle Linux 7 以及 Alma Linux 8、Oracle Linux 8、CentOS Linux 8 和 Rocky Linux 8 的转换到对应版本的 RHEL。

迁移步骤

配置 CentOS 7.9 和 RHEL 7.9 Yum Repo

CentOS-7-x86_64-DVD-2009.isorhel-server-7.9-x86_64-dvd.iso 挂载到运行 CentOS 7.x 的 VM 上

将 ISO 挂载到 文件系统

mkdir /mnt/centos79 /mnt/rhel79
mount /home/chenyh/CentOS-7-x86_64-DVD-2009-7.9.iso /mnt/centos79
mount /home/chenyh/rhel-server-7.9-x86_64-dvd.iso /mnt/rhel79

配置本地 Yum Repo

cat > /etc/yum.repos.d/centos79-local.repo << EOF 
[centos79-local-repo]
name = centos79 local repo
baseurl=file:///mnt/centos79
enabled=1
gpgcheck=0
EOF

cat > /etc/yum.repos.d/rhel79-local.repo << EOF 
[rhel79-local-repo]
name = rhel79 local repo
baseurl=file:///mnt/rhel79
enabled=1
gpgcheck=0
EOF

yum clean all
yum makecache
yum repolist

建议升级机器多,可配置一台ftp进行配置源,不然每台都要配置一遍

将 CentOS 7.x 原地更新至 CentOS 7.9(如果centos7.9转redhat7.9,此步骤可省略)

1.查看当前发行版和 kernel 版本

cat /etc/redhat-release
uname -r

2.确认 Yum Repo 只有 CentOS 7.9

如果有rhel79-local.repo源先删除

# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                 repo name                                      status
centos79-local-repo                     centos79 local repo                            4,070
repolist: 4,070

3.查看当前环境中所有可更新的软件包

yum list updates

4.开始更新 CentOS 7.x

yum update

5.确认被更新的 Package 和使用的 Repository。

。。。
Dependencies Resolved

=======================================================================================================================================================================
 Package                                         Arch                     Version                                          Repository                             Size
=======================================================================================================================================================================
Installing:
 grub2                                           x86_64                   1:2.02-0.86.el7.centos                           centos79-local-repo                    32 k
     replacing  grub2.x86_64 1:2.02-0.65.el7.centos.2
 grub2-tools                                     x86_64                   1:2.02-0.86.el7.centos                           centos79-local-repo                   1.8 M
     replacing  grub2-tools.x86_64 1:2.02-0.65.el7.centos.2
 grub2-tools-extra                               x86_64                   1:2.02-0.86.el7.centos                           centos79-local-repo                   1.0 M
     replacing  grub2-tools.x86_64 1:2.02-0.65.el7.centos.2
 grub2-tools-minimal                             x86_64                   1:2.02-0.86.el7.centos                           centos79-local-repo                   174 k
     replacing  grub2-tools.x86_64 1:2.02-0.65.el7.centos.2
 iwl7260-firmware                                noarch                   25.30.13.0-79.el7                                centos79-local-repo                   6.1 M
     replacing  iwl7265-firmware.noarch 22.0.7.0-62.el7
 kernel                                          x86_64                   3.10.0-1160.el7                                  centos79-local-repo                    50 M
Updating:
 GeoIP                                           x86_64                   1.5.0-14.el7                                     centos79-local-repo                   1.5 M
 acl                                             x86_64                   2.2.51-15.el7                                    centos79-local-repo                    81 k
 alsa-lib                                        x86_64                   1.1.8-1.el7 

6.完成后再次查看当前发行版和 kernel 版本

为了生效 kernel,需要重启 Linux

$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
$ uname -r
3.10.0-862.el7.x86_64

将 CentOS 7.9 原地迁移至 RHEL 7.9

安装 convert2rhel

使用 rpm 安装 convert2rhel,下载地址:https://github.com/oamg/convert2rhel/releases/download/v1.7.1/convert2rhel-1.7.1-1.el7.noarch.rpm

yum localinstall convert2rhel-1.7.1-1.el7.noarch.rpm

将 CentOS 7.9 转换到 RHEL 7.9

查看内核
[root@host8 chenyh]# uname -r
5.19.10-1.el7.elrepo.x86_64

内核降级

如果是非默认内核会提示错误,需要进行内核降级处理

# 内核降级
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
grub2-set-default "CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)"
1.执行以下命令查看已安装的非 CentOS 软件包及其供应商。
注意:convert2rhel 只转换由 CentOS 供应的软件。
rpm -qa --queryformat "%{VENDOR} = %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH} \n" | sort | grep -v "CentOS"

(none):mongodb-org-tools
(none):rabbitmq-server
Oracle and/or its affiliates:mysql-community-client
Oracle and/or its affiliates:mysql-community-common
Oracle and/or its affiliates:mysql-community-libs
Oracle and/or its affiliates:mysql-community-libs-compat
Oracle and/or its affiliates:mysql-community-server
Remi's RPM repository <https://rpms.remirepo.net/>:redis
Remi's RPM repository <https://rpms.remirepo.net/> #StandWithUkraine:remi-release
VMware, Inc.:erlang
2.确认当前可用 Yum Repo 有 CentOS 7.9 和 RHEL 7.9
yum repolist
3.执行命令,在迁移前先进行分析
convert2rhel analyze --no-rhsm --enablerepo=rhel79-local-repo
4.根据分析结果的返回ERRO结果的提示,设置以下环境变量(每台机器都不一样)
#跳过是否升为最新内核的检查
export CONVERT2RHEL_SKIP_KERNEL_CURRENCY_CHECK=1 
## 检查所有加载的内核模块在 RHEL 资源库中是否可用
export CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS=1 
# 跳过污点内核模块检查
export CONVERT2RHEL_TAINTED_KERNEL_MODULE_CHECK_SKIP=1 
#跳过对过期包的检查
export CONVERT2RHEL_OUTDATED_PACKAGE_CHECK_SKIP=1           
5.执行迁移
convert2rhel --no-rhsm --enablerepo=rhel79-local-repo
6.成功迁移后会有 “Conversion successful!” 提示。

image-20240731114815807

迁移过程的日志会写到 /var/log/convert2rhel/convert2rhel.log文件中

重启 Linux 后确认当前发行版和 kernel 版本已迁移到 RHEL 7.9

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)


# uname -r
3.10.0-1160.el7.x86_64

查看之前防火墙规则

iptables -xvnL
systemctl restart iptables
iptables -xvnL

删除Centos7.9源,避免与RedHat7.9源冲突

mv /etc/yum.repos.d/centos79-local.repo /etc/yum.repos.d/centos79-local.repo.bak

yum clean all
yum makecache
yum repolist

参考

1.https://blog.csdn.net/weixin_43902588/article/details/138306029

2.https://www.bilibili.com/video/BV1ix4y1i7c8/?spm_id_from=333.337.search-card.all.click

评论

  1. Windows Chrome 122.0.6261.95
    1 年前
    2024-7-31 17:08:02

    厉害了  需要操作这么多

    • 博主
      肥饶国学
      Windows Edge 118.0.2088.76
      1 年前
      2024-8-01 8:22:06

      咦~出现新访客了~

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇