用 convert2rhel 工具将 CentOS 转换成 RHEL

OpenShift 4.x HOL教程汇总
红帽提供的 convert2rhel 工具可以将现有 CentOS 操作系统自动转换至 RHEL。 本文以 CentOS 7.9 / RHEL 7.9 为例说明如何用 convert2rhel 工具将 CentOS转换至 RHEL。

CentOS 停更时间表

版本停更时间
CentOS 62020/11/30
CentOS 72024/6/30
CentOS 82021/12/1

CentOS 转换 RHEL 说明

确定现有 CentOS 和目标 RHEL 的版本

convert2rhel 工具支持对 CentOS 6/7/8 进行转换。在迁移 CentOS 的时候需要注意以下事项:

  1. convert2rhel 只支持从一个主版本的 CentOS 转换到对应版本的 RHEL,不能跨主版本转换。例如从 CentOS 7.9 只能直接转换到 RHEL 7.9,而不能直接转换到 RHEL 8。
  2. 根据使用的 convert2rhel 本版差异,从CentOS 到 RHEL 的单步迁移路径支持以下若干:
  • 直迁(即大小版本都不变)
CentOS 6.x --> RHEL 6.x			## 由于 RHEL6 已经过了版本运维周期,新版 convert2rhel 已不支持迁移 RHEL6,但老版 convert2rhel 支持
CentOS 6.10 --> RHEL 6.10		## 由于 RHEL6 已经过了版本运维周期,新版 convert2rhel 已不支持迁移 RHEL6,但老版 convert2rhel 支持
CentOS 7.x --> RHEL 7.x			## 由于版本运维周期原因,新版 convert2rhel 已不支持迁移低于 CentOS7.9 的版本,但老版 convert2rhel 支持
CentOS 7.9 --> RHEL 7.9			## 新版 convert2rhel 支持迁移 RHEL7.9 及其以上版本(RHEL8/RHEL9)
  • 更迁(即小版本更新)
CentOS 6.x --> RHEL 6.10		## 由于 RHEL6 已经过了版本运维周期,新版 convert2rhel 已不支持迁移 RHEL6,但老版 convert2rhel 支持
CentOS 7.x --> RHEL 7.9			## 由于版本运维周期原因,新版 convert2rhel 已不支持迁移低于 CentOS7.9 的版本,但老版 convert2rhel 支持
  1. 由于每个特定次要版本的 CentOS 7/8 所包含的内核版本也会定期更新(见 CentOS 内核版本RHEL 内核版本),因此即便是相同次要版本的 CentOS 7.9 和 RHEL 7.9,他们使用的内核版本也会有微小差异。转换过程不能对内核版本进行降级,即无法对内核已经升级到 3.10.0-1160.105.1.el7 的 CentOS 7.9 转换到内核为 3.10.0-1160.el7 的 RHEL 7.9。因此在转换时需要控制好 CentOS 和 RHEL 使用的 Yum 源,一般 ISO 中包含的是稍早版本的介质,而官方在线 Yum Repo 一般都是最新版本介质。

转换限制

有以下情况的 CentOS 无法直接将其转换到 RHEL:

  1. 不支持对使用 FIPS 模式运行的 CentOS 进行转换。
  2. 不支持对带有 RHEL 内核模块之外的运行环境进行直接转换(例如专用应用程序、设备动程序的内核模块)。可以先将这些内核模块禁用,在转换后再启动。

CentOS 转换 RHEL 示例

转换示例环境

本示例模拟以下环境,使用 RHEL 7.9 ISO 文件作为转换使用的 yum repository 源,因此需要以下环境即可:

  • 当前可运行的 CentOS 7.9 操作系统
  • RHEL 7.9 ISO 文件(rhel-server-7.9-x86_64-dvd.iso)

从CentOS 至 RHEL 转换过程

查看当前 CentOS版本

$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

在 CentOS 中安装 convert2rhel

  1. 方法1:在 CentOS 中执行命令,分别下载 convert2rhel.reop、Red Hat GPG 密钥、SSL 证书,然后安装 convert2rhel 工具。
$ curl -o /etc/yum.repos.d/convert2rhel.repo https://ftp.redhat.com/redhat/convert2rhel/7/convert2rhel.repo
$ curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release https://www.redhat.com/security/data/fd431d51.txt
$ curl --create-dirs -o /etc/rhsm/ca/redhat-uep.pem https://ftp.redhat.com/redhat/convert2rhel/redhat-uep.pem
$ yum -y install convert2rhel
  1. 方法2:在 CentOS 中执行命令,基于 “https://github.com/oamg/convert2rhel” 安装 convert2rhel。
$ yum install -y https://github.com/oamg/convert2rhel/releases/download/v1.6.0/convert2rhel-1.6.0-1.el7.noarch.rpm

配置本地 RHEL YUM Repository

  1. 将 rhel-server-7.9-x86_64-dvd.iso 文件传到 CentOS 中。
$ scp rhel-server-7.9-x86_64-dvd.iso root@<CENTOS-HOST>:/root/
  1. 在 CentOS 中执行命令,挂载RHEL的 ISO 文件
$ mkdir -p /mnt/rhiso
$ mount -o loop rhel-server-7.9-x86_64-dvd.iso /mnt/rhiso
  1. 在 CentOS 中执行命令,用挂载的RHEL文件配置 yum repository。
$ cat > /etc/yum.repos.d/rhel.repo << EOF
[RHEL7]
name=Red Hat Enterprise Linux 7
baseurl=file:///mnt/rhiso
enabled=1
EOF

如果是CentOS 8,需要执行以下命令。

$ cat > /etc/yum.repos.d/rhel.repo << EOF
[RHEL8-BaseOS]
name=Red Hat Enterprise Linux 8.0 BaseOS
baseurl=file:///mnt/rhiso/BaseOS/
enabled=1
 
[RHEL8-AppStream]
name=Red Hat Enterprise Linux 8.0 AppStream
baseurl=file:///mnt/rhiso/AppStream/
enabled=1
EOF

执行转换过程

  1. 执行以下命令,如果没有问题,convert2rhel 工具将自动完成转换 RHEL 7.9 的所有过程。
$ convert2rhel --disable-submgr --disablerepo=* --enablerepo=RHEL7 -y --no-rpm-va
。。。
[12/04/2021 04:38:52] TASK - [Prepare: Gather system information] *******************************
Name:                CentOS Linux
OS version:          7.9
Architecture:        x86_64
Config filename:     centos-7-x86_64.cfg
Skipping the execution of 'rpm -Va'.
。。。
[12/04/2021 04:39:05] TASK - [Convert: Prepare kernel] ******************************************
Installing RHEL kernel ...
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-
              : manager
。。。
Successfully downloaded the kernel-3.10.0-1160.el7 package.
Replacing CentOS Linux kernel-3.10.0-1160.el7 with RHEL kernel with the same NEVRA ...
 
RHEL kernel-3.10.0-1160.el7 installed.
 
Verifying that RHEL kernel has been installed
RHEL kernel has been installed.
Searching for non-RHEL kernels ...
Removing non-RHEL kernels
Package                                   Vendor/Packager  Repository
-------                                   ---------------  ----------
kernel-tools-3.10.0-1160.el7.x86_64       CentOS           anaconda
kernel-tools-libs-3.10.0-1160.el7.x86_64  CentOS           anaconda
 
Removing package: kernel-tools-3.10.0-1160.el7.x86_64
Removing package: kernel-tools-libs-3.10.0-1160.el7.x86_64
。。。
。。。
Removed:
  basesystem.noarch 0:10.0-7.el7.centos
  dhclient.x86_64 12:4.2.5-82.el7.centos
  dhcp-common.x86_64 12:4.2.5-82.el7.centos
  dhcp-libs.x86_64 12:4.2.5-82.el7.centos
  libxml2.x86_64 0:2.9.1-6.el7_9.6
  libxml2-python.x86_64 0:2.9.1-6.el7_9.6
  plymouth.x86_64 0:0.8.9-0.34.20140113.el7.centos
  plymouth-core-libs.x86_64 0:0.8.9-0.34.20140113.el7.centos
  plymouth-scripts.x86_64 0:0.8.9-0.34.20140113.el7.centos
  yum.noarch 0:3.4.3-168.el7.centos
 
Installed:
  basesystem.noarch 0:10.0-7.el7
  dhclient.x86_64 12:4.2.5-82.el7
  dhcp-common.x86_64 12:4.2.5-82.el7
  dhcp-libs.x86_64 12:4.2.5-82.el7
  libxml2.x86_64 0:2.9.1-6.el7.5
  libxml2-python.x86_64 0:2.9.1-6.el7.5
  plymouth.x86_64 0:0.8.9-0.34.20140113.el7
  plymouth-core-libs.x86_64 0:0.8.9-0.34.20140113.el7
  plymouth-scripts.x86_64 0:0.8.9-0.34.20140113.el7
  yum.noarch 0:3.4.3-168.el7
 
Dependency Installed:
  redhat-logos.noarch 0:70.7.0-1.el7
 
Complete!
Received return code: 0

如果是 CentOS 8,执行以下命令:

$ convert2rhel --disable-submgr --disablerepo=* --enablerepo RHEL8-BaseOS --enablerepo RHEL8-AppStream -y --no-rpm-va
  1. 查看系统版本,确认已经转换到 RHEL 7.9 了
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
  1. 最后重启及完成转换。
$ reboot

转换后

由于 CentOS 没有安装 subscription-manager,因此要注册 RHEL 订阅,需要运行以下命令安装相关软件包。

$ yum -y install subscription-manager subscription-manager-rhsm-certificates

参考

  • https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/converting_from_an_rpm-based_linux_distribution_to_rhel/index
  • https://access.redhat.com/zh_CN/articles/6754061
  • https://access.redhat.com/articles/5941531
  • RHEL 7/8 ISO REPO
  • https://access.redhat.com/articles/2360841
  • https://lab.redhat.com/tracks/convert2rhel
  • https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux/migration-process/convert2rhel-how-to-convert-from-centos-linux-to-red-hat-enterprise-linux
  • https://developers.redhat.com/articles/2023/04/11/how-use-convert2rhel-migrate-centos-rhel
  • https://www.redhat.com/zh/interactive-labs/migrate-red-hat-enterprise-linux-centos-linux
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值