文档

Red Hat Enterprise Linux(RHEL)7升级为RHEL 8

更新时间:

如果您的ECS实例及应用程序部署在RHEL 7上,希望升级到RHEL 8以获得新功能或者更好的性能,您可以参考本文在ECS实例上将RHEL 7直接升级为RHEL 8。

更多信息,请参见Red Hat官方文档

前提条件

需确保待升级的ECS实例满足RHEL 8系统运行的要求。具体要求,请参见RHEL 8的最低硬件要求

操作步骤

重要

升级操作有一定风险。在升级之前,建议创建一个云盘快照备份重要数据,了解升级过程和可能出现的问题,并谨慎操作。

  1. 使用root用户远程连接RHEL 7系统的ECS实例。

    具体操作,请参见通过密码或密钥认证登录Linux实例

  2. 准备升级环境。

    1. 运行以下命令,将RHEL 7系统升级到最新,并重启系统生效。

      yum -y update
      reboot
    2. 运行以下命令,在RHEL 7系统上安装Leapp升级工具。

      yum -y install leapp leapp-rhui-alibaba --enablerepo="*"
  3. 预升级检查。

    1. 运行以下命令,进行预升级检查。

      leapp preupgrade  --no-rhsm --target 8.8

      其中--target 8.8指定升级的目标版本为RHEL 8.8,您可以根据实际需求替换版本。如果不指定目标版本,默认升级至最新版本。

      说明

      您可以通过leapp preupgrade -h命令查看支持升级的目标版本。

    2. 查看预升级结果。

      Leapp预升级会对系统进行扫描检查,因为RHEL 7和RHEL 8的系统差异较大,需要修改部分配置以满足升级需求。Leapp工具预升级的检查日志保存在以下日志文件中:

      • /var/log/leapp/leapp-preupgrade.log:Leapp工具的日志

      • /var/log/leapp/leapp-report.txt:文本格式的预升级检查报告

      • /var/log/leapp/leapp-report.json :JSON格式的预升级检查报告

      预升级检查失败后,会打印出一些具体检查失败项, 如下图所示。

      image.png

    3. 处理预升级结果。

      您可以在日志文件/var/log/leapp/leapp-report.txt中查看具体的报告信息,并根据Leapp工具的建议进行修复。以下列出一些常见的预升级检查结果的处理办法。

      • 案例1:系统中安装了多个内核版本

        Risk Factor: high (inhibitor)
        Title: Multiple devel kernels installed
        Summary: DNF cannot produce a valid upgrade transaction when multiple kernel-devel packages are installed.
        Remediation: [hint] Remove all but one kernel-devel packages before running Leapp again.
        [command] yum -y remove kernel-devel-3.10.0-1160.11.1.el7

        处理办法:系统中安装了多个内核版本,需要卸载旧的内核包。您可以根据leapp工具的提示命令卸载旧内核,例如本案例中的yum -y remove kernel-devel-3.10.0-1160.11.1.el7

      • 案例2:系统中加载了RHEL 8不支持的内核模块

        Risk Factor: high (inhibitor)                                                                                                                                                                                         
        Title: Leapp detected loaded kernel drivers which have been removed in RHEL 8. Upgrade cannot proceed.                                                                                                                
        Summary: Support for the following RHEL 7 device drivers has been removed in RHEL 8:                                                                                                                                  
             - floppy

        处理办法:部分模块(例如本案例的floppy模块)在RHEL 8上不支持,您可以运行以下命令进行卸载。

        rmmod floppy
      • 案例3:sshd_config配置异常

        Risk Factor: high (inhibitor)
        Title: Possible problems with remote login using root account
        Summary: OpenSSH configuration file does not explicitly state the option PermitRootLogin in sshd_config file, which will default in RHEL8 to "prohibit-password".
        Remediation: [hint] If you depend on remote root logins using passwords, consider setting up a different user for remote administration or adding "PermitRootLogin yes" to sshd_config. 
        If this change is ok for you, add explicit "PermitRootLogin prohibit-password" to your sshd_config to ignore this inhibitor

        处理办法:

        1. 将配置文件/etc/sshd/sshd_config中的PermitRootLogin默认值配置为yes

          说明

          RHEL 7和RHEL 8的PermitRootLogin的默认值有差异:

          • RHEL 7:默认值为yes,表示允许root使用密码、密钥登录。

          • RHEL 8:默认值为prohibit-password,表示禁止密码登录。

        2. 运行以下命令,重启sshd服务。

          systemctl restart sshd
      • 案例4:没有编辑确认应答文件

        Risk Factor: high (inhibitor)
        Title: Missing required answers in the answer file
        Summary: One or more sections in answerfile are missing user choices: remove_pam_pkcs11_module_check.confirm
        For more information consult https://leapp.readthedocs.io/en/latest/dialogs.html
        Remediation: [hint] Please register user choices with leapp answer cli command or by manually editing the answerfile.
        [command] leapp answer --section remove_pam_pkcs11_module_check.confirm=True

        处理办法:本案例需要删除RHEL 8上不支持的pam模块,需要在应答文件/var/log/leapp/answerfile中确认,您可以运行以下命令将confirm设置为True进行确认。

        leapp answer --section remove_pam_pkcs11_module_check.confirm=True

        image.png

  4. 运行以下命令,进行升级。

    leapp upgrade  --no-rhsm --target 8.8

    如下图所示,表示升级成功。

    image.png

  5. 运行以下命令,重启进入新系统。

    reboot
  6. 升级后验证。

    • 查看升级的执行日志或报告是否正常。

      进入新的操作系统后,可以通过/var/log/leapp/leapp-upgrade.txt文件查看升级的执行日志,也可以通过/var/log/leapp/leapp-report.txt文件查看升级报告,报告中包含了升级系统的详细信息:

      • 如下日志信息表示一些软件包可能无法安装或升级,您可以在升级后手动安装丢失的软件包。

        Risk Factor: high
        Title: Packages from unknown repositories may not be installed
        Summary: 3 packages may not be installed or upgraded due to repositories unknown to leapp:
        - python3-pyxattr (repoid: rhel8-CRB)
        - rpcgen (repoid: rhel8-CRB)
        - ustr (repoid: rhel8-CRB)
        Remediation: [hint] In case the listed repositories are mirrors of official repositories for RHEL (provided by Red Hat on CDN) and their repositories IDs has been customized, you can change the configuration to use the official IDs instead of fixing the problem. You can also review the projected DNF upgrade transaction result in the logs to see what is going to happen, as this does not necessarily mean that the listed packages will not be upgraded. You can also install any missing packages after the in-place upgrade manually.
      • 如下日志信息表示RHEL 7的一些软件包未升级,您可以删除这些软件包以保持系统处于受支持的状态。

        Risk Factor: high
        Title: Some RHEL 7 packages have not been upgraded
        Summary: Following RHEL 7 packages have not been upgraded:
        leapp-upgrade-el7toel8-0.18.0-1.el7_9
        kernel-3.10.0-1160.92.1.el7
        leapp-rhui-alibaba-1.0.0-1.el7_9
        Please remove these packages to keep your system in supported state.

        删除命令:yum remove leapp-upgrade-el7toel8-0.18.0-1.el7_9 kernel-3.10.0-1160.92.1.el7 leapp-rhui-alibaba-1.0.0-1.el7_9

    • 观察您的业务在RHEL 8上运行是否正常。

  • 本页导读 (1)
文档反馈