CentOS 停更时间表
版本 | 停更时间 |
---|---|
CentOS 6 | 2020/11/30 |
CentOS 7 | 2024/6/30 |
CentOS 8 | 2021/12/1 |
支持的转换路径,表示官方测试过
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:在 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/v1.6.0/convert2rhel-1.6.0-1.el7.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
转换后
由于 CentOS 没有安装 subscription-manager,因此要注册 RHEL 订阅,需要运行以下命令安装相关软件包。
$ yum -y install subscription-manager subscription-manager-rhsm-certificates
参考资料
https://access.redhat.com/zh_CN/articles/6754061
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/converting_from_an_rpm-based_linux_distribution_to_rhel/con_supported-conversion-paths_converting-from-a-linux-distribution-to-rhel