2

CentOS 8 升级 RHEL 8

 1 year ago
source link: https://www.wyr.me/post/698
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

CentOS 8 升级 RHEL 8

CentOS 8 升级 RHEL 8

由于RedHat停止了CentOS8的支持,同时RedHat允许开发者注册16个正版RHEL系统,我决定将部分 CentOS 8 服务器更新到 RHEL 8。以下两篇文章是官方发布的与之密切相关的内容:

CentOS Project shifts focus to CentOS Stream

New Year, new Red Hat Enterprise Linux programs: Easier ways to access RHEL

注意,因参考本文操作导致的任何损失与鄙人无关,专业用户请直接访问官方升级说明(请注意官方源无法使用,因此部分sed命令需要修改):https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/converting_from_an_rpm-based_linux_distribution_to_rhel/index

关于为什么不选择升级至CentOS Stream?

一直以来我的客户都在使用正版RHEL系统,购买了即时的订阅,只有部分预算有限的客户使用了CentOS系统,但无论如何他们对于安全、稳定性或技术支持即时性的要求都很高。

能够得到官方的技术支持是我们更加看重的。

目前不支持从CentOS Stream转换/升级到RHEL8,不排除将来也不支持,如果后续有升级需求将不得不重装系统。同理,已经升级到CentOS Stream的用户就别折腾了,必须重装。(只是因为更新到vault源更新过软件,cat /etc/system-release却得到CentOS Stream release 8,说明实际已经升级到CentOS Stream了,是不可以升级到RHEL 8的。)

升级到RHEL 8的准备工作

  1. Red Hat Developer program中进行注册并确保 https://access.redhat.com/management/subscriptions 中存在可用的订阅。
  2. 创建快照,备份数据
  3. 【如果当前版本不是CentOS 8.5.2111】更新到8.5版本,先确认yum update可以执行,如果无法执行,更换为国内源(CentOS 8操作系统版本结束了生命周期,阿里云等部分国内镜像站也移除了相应镜像源)。

官方源 -> 清华源,仅用于升级到8.5。

sed -i 's|^baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' /etc/yum.repos.d/CentOS-*

阿里云、华为云等云服务商的官方CentOS镜像使用的源也无法正常更新到RHEL,因此需要替换为centos-vault源(已包含在第三步脚本里)。

  1. 无脑复制下述命令并执行(再次提醒,系统升级是高危操作,具有重要资料或专业用户请参考上述官方文档):
cp -rf /etc/yum.repos.d /etc/yum.repos.d.backup
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
rm -rf /etc/yum.repos.d/CentOS-*
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
sed -i 's/^failovermethod/#failovermethod/g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all && yum makecache
sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
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
curl -o /etc/yum.repos.d/convert2rhel.repo https://ftp.redhat.com/redhat/convert2rhel/8/convert2rhel.repo
yum -y install convert2rhel

说明:官方文档里面的命令有错误,并且现在官方早已停止了CentOS 8的支持,源站停止,导致无法更新,因此只能用国内镜像。

升级RHEL 8

convert2rhel --username 用户名 --password 密码

使用准备工作中第一步创建的Red Hat账号的账号密码替换上面的用户名密码,并执行命令。需要注意,用户名不是登录邮箱,用户名可以登录后右上角去找。

命令执行过程中会展示不支持的软件包以及会被移除的软件,例如Docker,绝大部分场景可以直接用podman代替docker,如果必须使用Docker可以参考我另外一篇博文《CentOS8卸载podman安装docker》。

命令执行过程会提示使用到的订阅信息,需要进行选择。

如果看到提示:

WARNING - ********************************************************
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.
WARNING - ********************************************************

之后千万不要手动退出,有些步骤会很慢类似假死,但是退出后将无法回滚。

等待 Convert2RHEL 安装 RHEL 包。

成功提示:

Conversion successful!

WARNING - In order to boot the RHEL kernel, restart of the system is needed.

一般情况下,命令执行完成后(升级大约需要2个小时),检查如果没啥红色信息,reboot重启即可。

如果升级过程出现错误,尝试回滚(Conversion rollback)或恢复备份。不过大部分情况也是无法回滚的,这种情况只能在命令后面增加--debug重新执行命令,同时对照https://github.com/oamg/convert2rhel/blob/main/convert2rhel/main.py的代码一步一步修改/usr/lib/python3.6/site-packages/convert2rhel/main.py进行调试。

升级后的检查

检查软件包,查看是否有不被支持的软件包:

yum list extras --disablerepo="*"

检查依赖关系:

yum check dependencies

查看订阅信息(留意到期时间):

sudo subscription-manager list --consumed

查看系统版本信息:

cat /etc/redhat-release

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK