《OpenShift 4.x HOL教程汇总》
本文以 CentOS 7.9 / RHEL 7.9 为例说明如何用 convert2rhel 工具将 CentOS 迁移至 RHEL。
版本 | 停更时间 |
---|---|
CentOS 6 | 2020/11/30 |
CentOS 7 | 2024/6/30 |
CentOS 8 | 2021/12/1 |
使用红帽提供的 convert2rhel 工具可以将现有 CentOS 操作系统自动迁移至 RHEL。 convert2rhel 工具支持对 CentOS 6/7/8 进行迁移。不过convert2rhel 工具只支持从一个主版本的 CentOS 迁移到对应版本的 RHEL,不能跨主版本进行迁移,例如从 CentOS 7.8 只能迁移到 7.8。在生产环境中,为了减少迁移过程的意外,最好当前和目标的迁移主版本和次版本都保持一致。
本示例模拟以下环境,使用 RHEL 7.9 ISO 文件作为迁移使用的 yum repository 源,因此需要以下环境即可:
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
$ 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
$ yum install -y https://github.com/oamg/convert2rhel/releases/download/v0.24/convert2rhel-0.24-1.el8.noarch.rpm
$ scp rhel-server-7.9-x86_64-dvd.iso root@<CENTOS-HOST>:/root/
$ mkdir -p /mnt/rhiso
$ mount -o loop rhel-server-7.9-x86_64-dvd.iso /mnt/rhiso
$ 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 --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
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
$ reboot