《OpenShift 4.x HOL教程汇总》
本文以 CentOS 7.9 / RHEL 7.9 为例说明如何用 convert2rhel 工具将 CentOS 迁移至 RHEL。
文章目录
CentOS 停更时间表
版本 | 停更时间 |
---|---|
CentOS 6 | 2020/11/30 |
CentOS 7 | 2024/6/30 |
CentOS 8 | 2021/12/1 |
将 CentOS 迁移至 RHEL
当前和目标的迁移版本
使用红帽提供的 convert2rhel 工具可以将现有 CentOS 操作系统自动迁移至 RHEL。 convert2rhel 工具支持对 CentOS 6/7/8 进行迁移。不过convert2rhel 工具只支持从一个主版本的 CentOS 迁移到对应版本的 RHEL,不能跨主版本进行迁移,例如从 CentOS 7.8 只能迁移到 7.8。在生产环境中,为了减少迁移过程的意外,最好当前和目标的迁移主版本和次版本都保持一致。
迁移示例环境
本示例模拟以下环境,使用 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:在 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
- 方法2:在 CentOS 中执行命令,基于 “https://github.com/oamg/convert2rhel” 安装 convert2rhel。
$ yum install -y https://github.com/oamg/convert2rhel/releases/download/v0.24/convert2rhel-0.24-1.el8.noarch.rpm
配置 RHEL YUM Repository
- 将 rhel-server-7.9-x86_64-dvd.iso 文件传到 CentOS 中。
$ scp rhel-server-7.9-x86_64-dvd.iso root@<CENTOS-HOST>:/root/
- 在 CentOS 中执行命令,挂载RHEL的 ISO 文件
$ mkdir -p /mnt/rhiso
$ mount -o loop rhel-server-7.9-x86_64-dvd.iso /mnt/rhiso
- 在 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
执行迁移
- 执行以下命令,如果没有问题,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
- 查看系统版本,确认已经迁移到 RHEL 7.9 了
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
- 最后重启及完成迁移。
$ reboot
参考
- 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/articles/5941531
- RHEL 7/8 ISO REPO
- https://access.redhat.com/articles/2360841
- https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux/migration-process/convert2rhel-how-to-convert-from-centos-linux-to-red-hat-enterprise-linux