• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

CentOS转换Redhat Enterprise Linux(一)6.x

Centos技术 zhangfanook 54次浏览 已收录 0个评论

随着CentOS社区项目将会转移到CentOS Stream,相信很多使用者会考虑将自家生产环境中的CentOS转换到Redhat Enterprise Linux,这样才能够保证企业基础架构和应用的稳定性。本篇文章简要介绍Convert2RHEL工具将CentOS的转换为RHEL的方法。

但需要注意的是,这里只是很简单的操作系统转换,真正在企业里做转换还需要考虑保证应用或数据库的高可用性,因此建议需请相应的人员提前做咨询工作。下面就看下大致的步骤:

  1. 这个演示我们利用CentOS 6.9进行实验。

CentOS转换Redhat Enterprise Linux(一)6.x

  1. 切换到/etc/yum.repos.d目录,这个位置是配置yum源的目录,以*.repo文件配置不同的yum源。将CentOS-Base.repo文件备份(改动配置前将原文件备份,是一个好习惯)。
[root@centos69-130 ~]# cd /etc/yum.repos.d
[root@centos69-130 yum.repos.d]# pwd
/etc/yum.repos.d
[root@centos69-130 yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak
  1. 因为CentOS 6.x已经不在支持周期,因此其yum源不在Redhat网站,我们需要将默认位置改到vault网站。
[root@centos69-130 yum.repos.d]# ls
CentOS-Base.repo      CentOS-Debuginfo.repo  CentOS-Media.repo  packagekit-media.repo
CentOS-Base.repo.bak  CentOS-fasttrack.repo  CentOS-Vault.repo
[root@centos69-130 yum.repos.d]# cat CentOS-Base.repo
[base-vault]
name=base-vault
baseurl=https://vault.centos.org/6.9/os/x86_64/
gpgcheck=0
enabled=1
  1. 因为转换工作主要是将各种CentOS package转换为RHEL package,因此我们需要将RHEL光盘镜像挂载并mount。

CentOS转换Redhat Enterprise Linux(一)6.x

  1. 将cdrom mount到文件系统。

    [root@centos69-130 ~]# 
    [root@centos69-130 ~]# mkdir /cdrom
    [root@centos69-130 ~]# mount /dev/cdrom /cdrom
    mount: block device /dev/sr0 is write-protected, mounting read-only
  2. 创建将RHEL cdrom作为yum源的repo文件RHEL-cdrom.repo
[root@centos69-130 yum.repos.d]# ls
CentOS-Base.repo      CentOS-Debuginfo.repo  CentOS-Media.repo  packagekit-media.repo
CentOS-Base.repo.bak  CentOS-fasttrack.repo  CentOS-Vault.repo  RHEL-cdrom.repo
[root@centos69-130 yum.repos.d]# cat RHEL-cdrom.repo 
[cdrom]
name=cdrom
baseurl=file:///cdrom
gpgcheck=0
enabled=1
  1. 如下我们配置了CentOS-Base.repo和RHEL-cdrom.repo两个文件,内容如下。

    [root@centos69-130 yum.repos.d]# ls
    CentOS-Base.repo      CentOS-Debuginfo.repo  CentOS-Media.repo  packagekit-media.repo
    CentOS-Base.repo.bak  CentOS-fasttrack.repo  CentOS-Vault.repo  RHEL-cdrom.repo
    [root@centos69-130 yum.repos.d]# cat CentOS-Base.repo
    [base-vault]
    name=base-vault
    baseurl=https://vault.centos.org/6.9/os/x86_64/
    gpgcheck=0
    enabled=1
    [root@centos69-130 yum.repos.d]# cat RHEL-cdrom.repo 
    [cdrom]
    name=cdrom
    baseurl=file:///cdrom
    gpgcheck=0
    enabled=1
  2. 更新yum源的cache。
[root@centos69-130 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: base-vault cdrom
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@centos69-130 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
base-vault                                                                                   | 3.7 kB     00:00     
base-vault/group_gz                                                                          | 226 kB     00:00     
base-vault/filelists_db                                                                      | 6.4 MB     00:04     
base-vault/primary_db                                                                        | 4.7 MB     00:03     
base-vault/other_db                                                                          | 2.8 MB     00:01     
cdrom                                                                                        | 4.1 kB     00:00 ... 
cdrom/group_gz                                                                               | 216 kB     00:00 ... 
cdrom/filelists_db                                                                           | 3.4 MB     00:00 ... 
cdrom/primary_db                                                                             | 3.1 MB     00:00 ... 
cdrom/other_db                                                                               | 1.3 MB     00:00 ... 
Metadata Cache Created
  1. 安装convert2rhel工具包。
[root@centos69-130 yum.repos.d]#  yum install -y https://github.com/oamg/convert2rhel/releases/download/v0.15/convert2rhel-0.15-1.el6.noarch.rpm
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
convert2rhel-0.15-1.el6.noarch.rpm                                                           |  83 kB     00:00 ... 
Examining /var/tmp/yum-root-PKw7Gm/convert2rhel-0.15-1.el6.noarch.rpm: convert2rhel-0.15-1.el6.noarch
  1. 因为我们使用本地源进行转换,所以暂时不需要向Redhat注册系统,先disable-submgr;后面加上参数配置yum源名称,和上面配置的名称一致;可以配置多个yum源。
[root@centos69-130 yum.repos.d]# convert2rhel --disable-submgr --enablerepo cdrom --debug

[01/29/2021 08:27:21] TASK - [Prepare: End user license agreement] ******************************
The following text is a copy of the November 2010 version of RHEL EULA [1].
For up-to-date version of RHEL EULA, please visit [2].
[1] https://www.redhat.com/f/pdf/licenses/GLOBAL_EULA_RHEL_English_20101110.pdf
[2] https://www.redhat.com/en/about/red-hat-end-user-license-agreements

END USER LICENSE AGREEMENT
RED HAT® ENTERPRISE LINUX® AND RED HAT APPLICATIONS
  1. 接受EULA

    Copyright © 2010 Red Hat, Inc. All rights reserved. "Red Hat" and the Red Hat "Shadowman" logo are registered trademarks of Red Hat, Inc. "Linux" is a registered trademark of Linus Torvalds. All other trademarks are the property of their respective owners.
    WARNING - By continuing you accept this EULA.
    Continue with the system conversion? [y/n]: y
  2. 确认一些package将会被替代,这一步等待时间会稍长
[01/29/2021 08:30:43] TASK - [Prepare: Gather system information] *******************************
Name:                CentOS
OS major version:    6
[01/29/2021 08:30:43] DEBUG - Calling command 'uname -i'
Architecture:        x86_64
Config filename:     centos-6-x86_64.cfg
Running the 'rpm -Va' command which can take several minutes. It can be disabled by using the --no-rpm-va option.
[01/29/2021 08:30:43] DEBUG - Calling command 'rpm -Va'
The 'rpm -Va' output has been stored in the /var/log/convert2rhel/rpm_va.log file
[01/29/2021 08:31:34] TASK - [Prepare: Determine RHEL variant] **********************************
Variant: Server
[01/29/2021 08:31:34] TASK - [Prepare: Backup System] *******************************************
Backing up /etc/system-release
Copying /etc/system-release to /var/lib/convert2rhel/
Backing up /etc/yum.conf
Copying /etc/yum.conf to /var/lib/convert2rhel/
[01/29/2021 08:31:34] TASK - [Prepare: Clear YUM/DNF version locks] *****************************
Usage of YUM/DNF versionlock plugin not detected.
[01/29/2021 08:31:34] TASK - [Convert: Remove excluded packages] ********************************
Searching for the following excluded packages:
centos-bookmarks ................................ 0
centos-logos .................................... 0
centos-indexhtml ................................ 1
centos-release* ................................. 1
redhat-release* ................................. 0
libreport-centos ................................ 0
libreport-plugin-mantisbt ....................... 0
rhn* ............................................ 0
yum-rhn-plugin .................................. 0
WARNING - The following packages will be removed...
Package                                 Packager            Repository
-------                                 --------            ----------
centos-indexhtml-6-2.el6.centos.noarch  CentOS BuildSystem  anaconda-CentOS-201703281317.x86_64
centos-release-6-9.el6.12.3.x86_64      CentOS BuildSystem  anaconda-CentOS-201703281317.x86_64
Continue with the system conversion? [y/n]: y
  1. 检测已安装的应用packages将会被替代,而一些第三方package则不会被替代
Backing up centos-indexhtml-6-2.el6.centos.noarch
[01/29/2021 08:33:02] DEBUG - Downloading the centos-indexhtml-6-2.el6.centos.noarch package.
[01/29/2021 08:33:02] DEBUG - Calling command 'yumdownloader -v --destdir="/var/lib/convert2rhel/" centos-indexhtml-6-2.el6.centos.noarch'
Loading "fastestmirror" plugin
Loading "refresh-packagekit" plugin
Config time: 0.008
Loading mirror speeds from cached hostfile
repo time: 0.001
Setting up Package Sacks
pkgsack time: 0.015
centos-indexhtml-6-2.el6.centos.noarch.rpm    50% [=================-                 ]  0.0 B/s |  46 kB     --:-- centos-indexhtml-6-2.el6.centos.noarch.rpm   100% [===================================]  71 kB/s |  91 kB     00:00 rpmdb time: 0.000
centos-indexhtml-6-2.el6.centos.noarch.rpm                                                       |  91 kB     00:00     
Successfully downloaded the centos-indexhtml-6-2.el6.centos.noarch package.
[01/29/2021 08:33:05] DEBUG - Path of the downloaded package: /var/lib/convert2rhel/centos-indexhtml-6-2.el6.centos.noarch.rpm
Backing up centos-release-6-9.el6.12.3.x86_64
[01/29/2021 08:33:05] DEBUG - Downloading the centos-release-6-9.el6.12.3.x86_64 package.
[01/29/2021 08:33:05] DEBUG - Calling command 'yumdownloader -v --destdir="/var/lib/convert2rhel/" centos-release-6-9.el6.12.3.x86_64'
Loading "fastestmirror" plugin
Loading "refresh-packagekit" plugin
Config time: 0.006
Loading mirror speeds from cached hostfile
repo time: 0.000
Setting up Package Sacks
pkgsack time: 0.013
rpmdb time: 0.000
centos-release-6-9.el6.12.3.x86_64.rpm                                                           |  22 kB     00:00     
Successfully downloaded the centos-release-6-9.el6.12.3.x86_64 package.
[01/29/2021 08:33:06] DEBUG - Path of the downloaded package: /var/lib/convert2rhel/centos-release-6-9.el6.12.3.x86_64.rpm
Removing package: centos-indexhtml-6-2.el6.centos.noarch
[01/29/2021 08:33:06] DEBUG - Calling command 'rpm -e --nodeps centos-indexhtml-6-2.el6.centos.noarch'
Removing package: centos-release-6-9.el6.12.3.x86_64
[01/29/2021 08:33:06] DEBUG - Calling command 'rpm -e --nodeps centos-release-6-9.el6.12.3.x86_64'
warning: /etc/yum.repos.d/CentOS-Base.repo saved as /etc/yum.repos.d/CentOS-Base.repo.rpmsave
[01/29/2021 08:33:07] DEBUG - Successfully removed 2 packages
[01/29/2021 08:33:07] TASK - [Convert: Install Red Hat release package] *************************
Installing redhat-release-server package
No package to install
[01/29/2021 08:33:07] TASK - [Convert: Patch yum configuration file] ****************************
[01/29/2021 08:33:07] DEBUG - /etc/yum.conf patched.
[01/29/2021 08:33:07] TASK - [Convert: List third-party packages] *******************************
WARNING - Only packages signed by CentOS are to be reinstalled. Red Hat support won't be provided for the following third party packages:
Package                         Packager  Repository
-------                         --------  ----------
convert2rhel-0.15-1.el6.noarch  N/A       /convert2rhel-0.15-1.el6.noarch
Continue with the system conversion? [y/n]: y
  1. 将要开始conversion,警告:直到此步之前都可以自动回滚,开始这步骤之后,如果需要回滚只能手工进行了。
WARNING - The tool allows rollback of any action until this point.
WARNING - By continuing all further changes on the system will need to be reverted manually by the user, if necessary.
Continue with the system conversion? [y/n]: y
  1. 将要开始替换成RHEL kernel
[01/29/2021 08:37:46] TASK - [Convert: Import Red Hat GPG keys] *********************************
[01/29/2021 08:37:46] DEBUG - Calling command 'rpm --import /usr/share/convert2rhel/gpg-keys/RPM-GPG-KEY-redhat-release'
[01/29/2021 08:37:46] DEBUG - Calling command 'rpm --import /usr/share/convert2rhel/gpg-keys/RPM-GPG-KEY-redhat-legacy-release'
[01/29/2021 08:37:46] TASK - [Convert: Prepare kernel] ******************************************
Installing RHEL kernel ...
[01/29/2021 08:37:46] DEBUG - Calling command 'yum install -y --disablerepo=* --enablerepo=cdrom kernel'
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Determining fastest mirrors
Package kernel-2.6.32-696.el6.x86_64 already installed and latest version
Nothing to do
Conflict of kernels: One of the installed kernels has the same version as the latest RHEL kernel.
[01/29/2021 08:37:47] DEBUG - Calling command 'yum list -y --disablerepo=* --enablerepo=cdrom --showduplicates kernel'
WARNING - The convert2rhel is going to force-replace the only kernel installed, which has the same NEVRA as the only available RHEL kernel. If anything goes wrong with such replacement, the system will become unbootable. If you want the convert2rhel to install the RHEL kernel in a safer manner, you can install a different version of kernel first and then run convert2rhel again.
Continue with the system conversion? [y/n]: y
  1. 接下来就是正式开始进行转换,等待段时间后就完成啦!然后需要重启。
[01/29/2021 08:44:26] TASK - [Final: Non-interactive mode] **************************************
For the non-interactive use of the tool, run the following command:
convert2rhel --disable-submgr  --disablerepo=*  --enablerepo=cdrom  -v Server -y
WARNING - In order to boot the RHEL kernel, restart of the system is needed.
[root@centos69-130 yum.repos.d]# reboot
  1. 重启后看到已经转换成Redhat Enterprise Linux啦!

CentOS转换Redhat Enterprise Linux(一)6.x


VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明CentOS转换Redhat Enterprise Linux(一)6.x
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址