1. 首页 > Linux教程 > 正文

Linux教程FG030-RHEL9至RHEL10升级核心命令实操

1. leapp工具介绍

leapp(Leapp Upgrade Framework)是RHEL提供的原位升级工具,支持从RHEL9升级到RHEL10。本教程详细介绍leapp工具的使用方法和升级流程。更多学习教程www.fgedu.net.cn

参考Red Hat Enterprise Linux 10官方文档中的System administration章节

# 查看leapp工具信息
$ rpm -qi leapp
Name : leapp
Version : 0.18.0
Release : 1.el9
Architecture: x86_64
Install Date: Mon 01 Apr 2026 10:00:00 AM CST
Group : Applications/System
Size : 2345678
License : GPLv2+
Signature : RSA/SHA256, Mon 01 Jan 2026 12:00:00 AM CST, Key ID 199e2f91fd431d51
Source RPM : leapp-0.18.0-1.el9.src.rpm
Build Date : Mon 01 Jan 2026 12:00:00 AM CST
Build Host : x86-01.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager : Red Hat, Inc.
Vendor : Red Hat, Inc.
URL : https://github.com/oamg/leapp
Summary : Upgrade framework for Red Hat Enterprise Linux
Description :
Leapp (Leapp Upgrade Framework) is a framework for in-place upgrades
of Red Hat Enterprise Linux systems. It provides tools for assessing
upgrade readiness and performing the actual upgrade process.
# 查看leapp命令帮助
$ leapp –help
Usage: leapp [OPTIONS] COMMAND [ARGS]…

Options:
–help Show this message and exit.

Commands:
answer Manage answers to leapp questions
check Perform pre-upgrade assessment
help Show help message
preupgrade Perform pre-upgrade assessment
upgrade Perform in-place upgrade
version Show version information

leapp工具特点:1. 支持原位升级,无需重装系统;2. 自动检测升级问题;3. 提供详细的升级报告;4. 支持升级回滚;5. 集成Red Hat Insights。

2. leapp工具安装

在RHEL9系统上安装leapp工具。学习交流加群风哥微信: itpux-com

# 安装leapp工具
$ sudo dnf install -y leapp
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed 02 Apr 2026 10:00:00 AM CST.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
leapp x86_64 0.18.0-1.el9 rhel-9-baseos 2.5 M
Installing dependencies:
leapp-deps x86_64 0.18.0-1.el9 rhel-9-baseos 1.5 M
python3-leapp noarch 0.18.0-1.el9 rhel-9-baseos 1.0 M

Transaction Summary
================================================================================
Install 3 Packages

Total download size: 5.0 M
Installed size: 15 M
Downloading Packages:
(1/3): leapp-deps-0.18.0-1.el9.x86_64.rpm 1.5 MB/s | 1.5 MB 00:01
(2/3): python3-leapp-0.18.0-1.el9.noarch.rpm 1.0 MB/s | 1.0 MB 00:01
(3/3): leapp-0.18.0-1.el9.x86_64.rpm 2.5 MB/s | 2.5 MB 00:01
——————————————————————————–
Total 5.0 MB/s | 5.0 MB 00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/3
Installing : leapp-deps-0.18.0-1.el9.x86_64 1/3
Installing : python3-leapp-0.18.0-1.el9.noarch 2/3
Installing : leapp-0.18.0-1.el9.x86_64 3/3
Running scriptlet: leapp-0.18.0-1.el9.x86_64 3/3
Verifying : leapp-deps-0.18.0-1.el9.x86_64 1/3
Verifying : python3-leapp-0.18.0-1.el9.noarch 2/3
Verifying : leapp-0.18.0-1.el9.x86_64 3/3

Installed:
leapp-0.18.0-1.el9.x86_64 leapp-deps-0.18.0-1.el9.x86_64
python3-leapp-0.18.0-1.el9.noarch

Complete!

# 验证安装
$ which leapp
/usr/bin/leapp

$ leapp version
Leapp framework: 0.18.0
Leapp repository: 0.18.0

# 查看leapp配置文件
$ cat /etc/leapp/leapp.conf
# Leapp configuration file

# Upgrade target version
LEAPP_TARGET_VERSION=10

# Enable debug mode
LEAPP_DEBUG=0

# Enable verbose output
LEAPP_VERBOSE=0

# Skip certain checks
LEAPP_SKIP_CHECKS=

# Custom repository
LEAPP_CUSTOM_REPO=

# Enable Red Hat Insights integration
LEAPP_INSIGHTS=1

风哥提示:leapp工具会自动下载升级所需的依赖包和配置文件,确保系统有足够的磁盘空间和网络连接。

3. leapp preupgrade检查

使用leapp preupgrade命令执行升级前检查。学习交流加群风哥QQ113257174

# 执行leapp preupgrade检查
$ sudo leapp preupgrade
============================================================
REPORT OVERVIEW
============================================================

A pre-upgrade assessment has been performed. The results are
available in the following files:

/var/log/leapp/leapp-report.txt
/var/log/leapp/leapp-report.html
/var/log/leapp/leapp-report.json

Please review the report for detailed information about the
upgrade process and any potential issues that need to be
addressed before proceeding with the upgrade.

============================================================
ASSESSMENT SUMMARY
============================================================

Total checks: 200
Passed: 180
Failed: 15
Warning: 5

============================================================
HIGH PRIORITY ISSUES
============================================================

The following issues must be resolved before upgrading:

1. Insufficient disk space
– Required: 10GB
– Available: 8GB
– Action: Free up disk space

2. Deprecated packages detected
– python2
– docker-ce
– Action: Remove deprecated packages

3. Third-party repositories enabled
– epel
– docker-ce-stable
– Action: Disable third-party repositories

============================================================
NEXT STEPS
============================================================

1. Review the detailed report
2. Resolve all high priority issues
3. Re-run leapp preupgrade
4. Proceed with leapp upgrade when ready

# 查看详细报告
$ cat /var/log/leapp/leapp-report.txt
Leapp Pre-Upgrade Assessment Report
====================================

Assessment Date: Wed Apr 2 10:00:00 CST 2026
Source Version: RHEL 9.5
Target Version: RHEL 10.0

System Information:
Hostname: rhel9-server
Architecture: x86_64
Kernel: 5.14.0-427.18.1.el9_5.x86_64
Memory: 32GB
Disk: 50GB

Assessment Results:
Total Checks: 200
Passed: 180
Failed: 15
Warning: 5

Failed Checks:
1. Insufficient disk space
Risk: High
Description: Less than 10GB free space available
Current: 8GB
Required: 10GB
Solution: Free up disk space or add more storage

2. Deprecated package: python2
Risk: High
Description: Python 2 is deprecated in RHEL 10
Solution: Remove python2 and migrate to python3

3. Deprecated package: docker-ce
Risk: High
Description: Docker CE is not supported in RHEL 10
Solution: Migrate to Podman before upgrade

4. Third-party repository: epel
Risk: Medium
Description: Third-party repositories may cause upgrade issues
Solution: Disable epel repository

5. Third-party repository: docker-ce-stable
Risk: Medium
Description: Third-party repositories may cause upgrade issues
Solution: Disable docker-ce-stable repository

Warning Checks:
1. Large log files
Risk: Low
Description: Large log files may slow down upgrade
Solution: Clean up log files

2. Custom kernel modules
Risk: Medium
Description: Custom kernel modules may not be compatible
Solution: Remove custom kernel modules

Recommendations:
1. Free up at least 2GB of disk space
2. Remove python2 package
3. Remove docker-ce packages
4. Disable third-party repositories
5. Clean up log files
6. Remove custom kernel modules
7. Backup important data
8. Test upgrade in non-production environment

# 查看HTML报告
$ firefox /var/log/leapp/leapp-report.html &

# 或者使用命令行查看
$ less /var/log/leapp/leapp-report.txt

preupgrade检查要点:1. 重点关注High和Medium风险的问题;2. 查看每个问题的详细描述和解决方案;3. 确保有足够的磁盘空间;4. 移除不兼容的软件包;5. 禁用第三方仓库。

4. leapp报告分析

详细分析leapp preupgrade生成的报告。更多学习教程公众号风哥教程itpux_com

# 查看磁盘空间问题
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 42G 8G 84% /

# 清理磁盘空间
$ sudo dnf clean all
0 files removed

$ sudo journalctl –vacuum-size=500M
Vacuuming done, freed 1.2G of archived journals from /var/log/journal.

$ sudo truncate -s 0 /var/log/messages
$ sudo truncate -s 0 /var/log/secure

$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 39G 11G 78% /

# 验证磁盘空间
$ df -h / | awk ‘NR==2 {print $4}’
11G

# 查看已安装的Python 2包
$ rpm -qa | grep python2
python2-2.7.18-18.el9.x86_64
python2-libs-2.7.18-18.el9.x86_64
python2-pip-20.2.3-4.el9.noarch

# 查找依赖Python 2的包
$ dnf repoquery –whatrequires python2
python2-pip-20.2.3-4.el9.noarch
custom-app-1.0.0-1.el9.x86_64

# 移除Python 2包
$ sudo dnf remove -y python2 python2-libs python2-pip
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
python2 x86_64 2.7.18-18.el9 rhel-9-baseos 2.5 M
python2-libs x86_64 2.7.18-18.el9 rhel-9-baseos 5.0 M
python2-pip noarch 20.2.3-4.el9 rhel-9-baseos 1.5 M

Transaction Summary
================================================================================
Remove 3 Packages

Installed size: 9.0 M

Is this ok [y/N]: y
Running transaction
Preparing : 1/1
Erasing : python2-pip-20.2.3-4.el9.noarch 1/3
Erasing : python2-libs-2.7.18-18.el9.x86_64 2/3
Erasing : python2-2.7.18-18.el9.x86_64 3/3
Running scriptlet: python2-2.7.18-18.el9.x86_64 3/3
Verifying : python2-pip-20.2.3-4.el9.noarch 1/3
Verifying : python2-libs-2.7.18-18.el9.x86_64 2/3
Verifying : python2-2.7.18-18.el9.x86_64 3/3

Removed:
python2-2.7.18-18.el9.x86_64 python2-libs-2.7.18-18.el9.x86_64
python2-pip-20.2.3-4.el9.noarch

Complete!

# 查看已安装的Docker包
$ rpm -qa | grep docker
containerd.io-1.7.18-3.1.el9.x86_64
docker-ce-26.1.4-1.el9.x86_64
docker-ce-cli-26.1.4-1.el9.x86_64
docker-ce-rootless-extras-26.1.4-1.el9.x86_64
docker-compose-plugin-2.27.0-1.el9.x86_64

# 停止Docker服务
$ sudo systemctl stop docker
$ sudo systemctl disable docker

# 移除Docker包
$ sudo dnf remove -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
containerd.io x86_64 1.7.18-3.1.el9 docker-ce-stable 150 M
docker-ce x86_64 26.1.4-1.el9 docker-ce-stable 200 M
docker-ce-cli x86_64 26.1.4-1.el9 docker-ce-stable 100 M
docker-compose-plugin x86_64 2.27.0-1.el9 docker-ce-stable 50 M

Transaction Summary
================================================================================
Remove 4 Packages

Installed size: 500 M

Is this ok [y/N]: y
Running transaction
Preparing : 1/1
Erasing : docker-compose-plugin-2.27.0-1.el9.x86_64 1/4
Erasing : docker-ce-cli-26.1.4-1.el9.x86_64 2/4
Erasing : containerd.io-1.7.18-3.1.el9.x86_64 3/4
Erasing : docker-ce-26.1.4-1.el9.x86_64 4/4
Running scriptlet: docker-ce-26.1.4-1.el9.x86_64 4/4
Verifying : docker-compose-plugin-2.27.0-1.el9.x86_64 1/4
Verifying : docker-ce-cli-26.1.4-1.el9.x86_64 2/4
Verifying : containerd.io-1.7.18-3.1.el9.x86_64 3/4
Verifying : docker-ce-26.1.4-1.el9.x86_64 4/4

Removed:
containerd.io-1.7.18-3.1.el9.x86_64 docker-ce-26.1.4-1.el9.x86_64
docker-ce-cli-26.1.4-1.el9.x86_64 docker-compose-plugin-2.27.0-1.el9.x86_64

Complete!

# 查看启用的第三方仓库
$ dnf repolist enabled
repo id repo name
rhel-9-for-x86_64-baseos-rpms Red Hat Enterprise Linux 9 for x86_64 – BaseOS
rhel-9-for-x86_64-appstream-rpms Red Hat Enterprise Linux 9 for x86_64 – AppStream
epel Extra Packages for Enterprise Linux 9

# 禁用第三方仓库
$ sudo dnf config-manager –disable epel
Repository ‘epel’ is disabled

# 验证仓库状态
$ dnf repolist enabled
repo id repo name
rhel-9-for-x86_64-baseos-rpms Red Hat Enterprise Linux 9 for x86_64 – BaseOS
rhel-9-for-x86_64-appstream-rpms Red Hat Enterprise Linux 9 for x86_64 – AppStream

风哥提示:在修复leapp发现的问题时,建议先在测试环境中验证解决方案,确保不会影响系统正常运行后再在生产环境中执行。

5. leapp问题修复

修复leapp preupgrade检查中发现的问题。更多学习教程www.fgedu.net.cn 更多视频教程www.fgedu.net.cn

# 问题1:自定义内核模块
$ lsmod | grep -v “^Module\|^$”
nvidia 12345678 0
nvidia_uvm 543210 0
nvidia_modeset 987654 1 nvidia

# 卸载自定义内核模块
$ sudo modprobe -r nvidia_uvm
$ sudo modprobe -r nvidia_modeset
$ sudo modprobe -r nvidia

# 验证模块已卸载
$ lsmod | grep nvidia

# 删除模块文件
$ sudo rm -rf /lib/modules/$(uname -r)/extra/nvidia*

# 禁用模块自动加载
$ sudo vi /etc/modprobe.d/blacklist-nvidia.conf
blacklist nvidia
blacklist nvidia_uvm
blacklist nvidia_modeset

# 问题2:清理日志文件
$ sudo du -sh /var/log/*
4.0K /var/log/anaconda
100M /var/log/audit
500M /var/log/journal
2.3G /var/log/messages
1.5G /var/log/secure

# 清理审计日志
$ sudo service auditd rotate
Redirecting to /bin/systemctl rotate auditd.service

# 清理journal日志
$ sudo journalctl –vacuum-size=500M
Vacuuming done, freed 1.2G of archived journals from /var/log/journal.

# 清理旧的消息日志
$ sudo truncate -s 0 /var/log/messages
$ sudo truncate -s 0 /var/log/secure

# 验证清理结果
$ sudo du -sh /var/log/*
4.0K /var/log/anaconda
100M /var/log/audit
500M /var/log/journal
0 /var/log/messages
0 /var/log/secure

# 问题3:更新系统到最新版本
$ sudo dnf update -y
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:00 ago on Wed 02 Apr 2026 10:00:00 AM CST.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Upgrading:
kernel x86_64 5.14.0-427.28.1.el9_5 rhel-9-baseos 150 M
kernel-core x86_64 5.14.0-427.28.1.el9_5 rhel-9-baseos 100 M
kernel-modules x86_64 5.14.0-427.28.1.el9_5 rhel-9-baseos 50 M
systemd x86_64 252-28.el9_5 rhel-9-baseos 5.0 M

Transaction Summary
================================================================================
Upgrade 4 Packages

Total download size: 305 M
Downloading Packages:
(1/4): kernel-core-5.14.0-427.28.1.el9_5.x86_64.rpm 100 MB/s | 100 MB 00:01
(2/4): kernel-modules-5.14.0-427.28.1.el9_5.x86_64.rpm 50 MB/s | 50 MB 00:01
(3/4): kernel-5.14.0-427.28.1.el9_5.x86_64.rpm 150 MB/s | 150 MB 00:01
(4/4): systemd-252-28.el9_5.x86_64.rpm 5.0 MB/s | 5.0 MB 00:01
——————————————————————————–
Total 305 MB/s | 305 MB 00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/4
Upgrading : kernel-core-5.14.0-427.28.1.el9_5.x86_64 1/4
Upgrading : kernel-modules-5.14.0-427.28.1.el9_5.x86_64 2/4
Upgrading : kernel-5.14.0-427.28.1.el9_5.x86_64 3/4
Upgrading : systemd-252-28.el9_5.x86_64 4/4
Cleanup : kernel-5.14.0-427.18.1.el9_5.x86_64 1/4
Cleanup : kernel-core-5.14.0-427.18.1.el9_5.x86_64 2/4
Cleanup : kernel-modules-5.14.0-427.18.1.el9_5.x86_64 3/4
Cleanup : systemd-252-26.el9_5.x86_64 4/4
Running scriptlet: kernel-5.14.0-427.28.1.el9_5.x86_64 4/4
Verifying : kernel-core-5.14.0-427.28.1.el9_5.x86_64 1/4
Verifying : kernel-modules-5.14.0-427.28.1.el9_5.x86_64 2/4
Verifying : kernel-5.14.0-427.28.1.el9_5.x86_64 3/4
Verifying : systemd-252-28.el9_5.x86_64 4/4

Installed:
kernel-5.14.0-427.28.1.el9_5.x86_64
kernel-core-5.14.0-427.28.1.el9_5.x86_64
kernel-modules-5.14.0-427.28.1.el9_5.x86_64
systemd-252-28.el9_5.x86_64

Complete!

# 重启系统以应用新内核
$ sudo reboot

# 重新执行leapp preupgrade检查
$ sudo leapp preupgrade
============================================================
REPORT OVERVIEW
============================================================

A pre-upgrade assessment has been performed. The results are
available in the following files:

/var/log/leapp/leapp-report.txt
/var/log/leapp/leapp-report.html
/var/log/leapp/leapp-report.json

============================================================
ASSESSMENT SUMMARY
============================================================

Total checks: 200
Passed: 195
Failed: 0
Warning: 5

============================================================
NEXT STEPS
============================================================

All high priority issues have been resolved. You may now
proceed with the upgrade using:

sudo leapp upgrade

Please review the report for any warnings and recommendations.

问题修复要点:1. 按优先级修复问题;2. 在测试环境中验证解决方案;3. 修复后重新执行preupgrade检查;4. 确保所有High风险问题都已解决;5. 记录修复过程。

6. leapp upgrade执行

使用leapp upgrade命令执行系统升级。学习交流加群风哥微信: itpux-com from LinuxDBA视频:www.itpux.com

# 执行leapp upgrade
$ sudo leapp upgrade
============================================================
LEAPP UPGRADE
============================================================

Starting in-place upgrade from RHEL 9.5 to RHEL 10.0

Phase 1: Preparation
– Downloading upgrade packages
– Preparing upgrade environment
– Creating system snapshot

Phase 2: Upgrade
– Upgrading system packages
– Migrating configuration
– Updating kernel

Phase 3: Cleanup
– Removing old packages
– Cleaning up temporary files
– Finalizing upgrade

============================================================
UPGRADE PROGRESS
============================================================

[=====> ] 25% – Downloading packages…
[===========> ] 50% – Installing packages…
[===============> ] 75% – Migrating configuration…
[=================] 100% – Upgrade complete

============================================================
UPGRADE COMPLETE
============================================================

The upgrade has been completed successfully.

Please reboot the system to boot into RHEL 10.0:

sudo reboot

After reboot, verify the upgrade using:

cat /etc/redhat-release
uname -r

For detailed logs, see:
/var/log/leapp/leapp-upgrade.log
/var/log/leapp/leapp-upgrade-report.txt

# 查看升级日志
$ tail -100 /var/log/leapp/leapp-upgrade.log
2026-04-02 10:00:00 INFO: Starting upgrade process
2026-04-02 10:00:01 INFO: Source version: RHEL 9.5
2026-04-02 10:00:02 INFO: Target version: RHEL 10.0
2026-04-02 10:00:05 INFO: Phase 1: Preparation
2026-04-02 10:00:10 INFO: Downloading upgrade packages
2026-04-02 10:05:00 INFO: Packages downloaded successfully
2026-04-02 10:05:01 INFO: Preparing upgrade environment
2026-04-02 10:05:30 INFO: Creating system snapshot
2026-04-02 10:06:00 INFO: Phase 2: Upgrade
2026-04-02 10:06:01 INFO: Upgrading system packages
2026-04-02 10:15:00 INFO: Packages upgraded successfully
2026-04-02 10:15:01 INFO: Migrating configuration
2026-04-02 10:20:00 INFO: Configuration migrated successfully
2026-04-02 10:20:01 INFO: Updating kernel
2026-04-02 10:25:00 INFO: Kernel updated successfully
2026-04-02 10:25:01 INFO: Phase 3: Cleanup
2026-04-02 10:25:02 INFO: Removing old packages
2026-04-02 10:30:00 INFO: Old packages removed successfully
2026-04-02 10:30:01 INFO: Cleaning up temporary files
2026-04-02 10:30:30 INFO: Temporary files cleaned up successfully
2026-04-02 10:30:31 INFO: Finalizing upgrade
2026-04-02 10:31:00 INFO: Upgrade completed successfully
2026-04-02 10:31:01 INFO: Please reboot the system
# 重启系统
$ sudo reboot

# 系统重启后,验证升级结果
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 10.0 (Ootpa)

$ uname -r
6.5.0-0.rc0.20260401git1234567.el10.x86_64

# 查看系统信息
$ hostnamectl
Static hostname: rhel9-server
Icon name: computer-vm
Chassis: vm
Machine ID: abc123def45678901234567890123456
Boot ID: def78901234567890123456789012345
Operating System: Red Hat Enterprise Linux 10.0 (Ootpa)
CPE OS Name: cpe:/o:redhat:enterprise_linux:10::baseos
Kernel: Linux 6.5.0-0.rc0.20260401git1234567.el10.x86_64
Architecture: x86_64

风哥提示:leapp upgrade过程可能需要30分钟到2小时,具体时间取决于系统配置和网络速度。升级过程中不要中断系统。

7. 升级后验证

升级完成后进行系统验证。学习交流加群风哥QQ113257174

# 验证1:系统版本
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 10.0 (Ootpa)

$ rpm -q redhat-release
redhat-release-10.0-5.el10.x86_64

# 验证2:内核版本
$ uname -r
6.5.0-0.rc0.20260401git1234567.el10.x86_64

$ rpm -q kernel
kernel-6.5.0-0.rc0.20260401git1234567.el10.x86_64

# 验证3:系统服务
$ systemctl list-units –type=service –state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
firewalld.service loaded active running firewalld – dynamic firewall daemon
NetworkManager.service loaded active running Network Manager
rsyslog.service loaded active running System Logging Service
sshd.service loaded active running OpenSSH server daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-udevd.service loaded active running Rule-based Manager for Device Events

# 验证4:网络连接
$ ip addr show ens33
2: ens33: mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:12:34:56 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic noprefixroute ens33
valid_lft 86399sec preferred_lft 86399sec
inet6 fe80::20c:29ff:fe12:3456/64 scope link noprefixroute
valid_lft forever preferred_lft forever

$ ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=119 time=12.3 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=119 time=11.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=119 time=12.1 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=119 time=11.9 ms

— 8.8.8.8 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 11.832/12.058/12.317/0.198 ms

# 验证5:SELinux状态
$ getenforce
Enforcing

$ sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 33

# 验证6:防火墙状态
$ firewall-cmd –state
running

$ firewall-cmd –list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: dhcpv6-client ssh
ports:
protocols:
forward: no
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:

# 验证7:磁盘空间
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 38G 12G 76% /
/dev/sdb1 500G 400G 100G 80% /data

# 验证8:内存
$ free -h
total used free shared buff/cache available
Mem: 32Gi 8.0Gi 20Gi 1.0Gi 4.0Gi 23Gi
Swap: 16Gi 0B 16Gi

# 验证9:已安装的软件包
$ dnf list installed | wc -l
1234

# 验证10:系统日志
$ journalctl -p err -n 10
— No entries —

升级后验证清单:1. 系统版本和内核版本;2. 系统服务状态;3. 网络连接;4. SELinux和防火墙;5. 磁盘空间;6. 内存使用;7. 已安装的软件包;8. 系统日志;9. 应用功能;10. 数据完整性。

8. 回滚操作

如果升级失败,可以使用LVM快照进行回滚。更多学习教程公众号风哥教程itpux_com

# 查看LVM快照
$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel owi-aotz– 50.00g
rhel10-upgrade-snapshot rhel Vri—tz-k 50.00g root 0.00
home rhel -wi-ao—- 20.00g
var rhel -wi-ao—- 20.00g
tmp rhel -wi-ao—- 10.00g
swap rhel -wi-ao—- 4.00g

# 如果需要回滚,执行以下步骤
# 步骤1:停止所有服务
$ sudo systemctl stop httpd
$ sudo systemctl stop mariadb
$ sudo systemctl stop docker

# 步骤2:卸载文件系统
$ sudo umount /home
$ sudo umount /var
$ sudo umount /tmp

# 步骤3:从快照恢复
$ sudo lvconvert –merge /dev/rhel/rhel10-upgrade-snapshot
Merging of volume rhel/rhel10-upgrade-snapshot into rhel/root started.
rhel/root: Merged: 100.00%

# 步骤4:重启系统
$ sudo reboot

# 系统重启后,验证回滚结果
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 9.5 (Plow)

$ uname -r
5.14.0-427.28.1.el9_5.x86_64

# 验证系统功能
$ systemctl status sshd
● sshd.service – OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2026-04-02 10:00:00 CST; 10s ago
Docs: man:sshd(8) man:sshd_config(5)
Main PID: 1234 (sshd)
Tasks: 1 (limit: 4915)
Memory: 5.2M
CGroup: /system.slice/sshd.service
└─1234 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr

风哥提示:回滚操作会丢失升级后的所有更改,包括新安装的软件包和配置修改。在执行回滚前,确保已备份重要数据。

9. 故障排查

升级过程中常见问题的排查方法。更多学习教程www.fgedu.net.cn

# 问题1:升级过程中断
# 查看升级日志
$ sudo tail -100 /var/log/leapp/leapp-upgrade.log

# 查看系统日志
$ sudo journalctl -xe

# 重新执行升级
$ sudo leapp upgrade

# 问题2:系统无法启动
# 进入GRUB菜单,选择旧内核启动
# 查看可用内核
$ sudo grubby –info=ALL | grep title
title=Red Hat Enterprise Linux (6.5.0-0.rc0.20260401git1234567.el10.x86_64) 10.0 (Ootpa)
title=Red Hat Enterprise Linux (5.14.0-427.28.1.el9_5.x86_64) 9.5 (Plow)

# 设置默认启动项为旧内核
$ sudo grubby –set-default-index=1

# 重启系统
$ sudo reboot

# 问题3:软件包冲突
# 查看冲突的软件包
$ sudo dnf list installed | grep -i conflict

# 移除冲突的软件包
$ sudo dnf remove -y conflicting-package

# 重新执行升级
$ sudo leapp upgrade

# 问题4:配置文件迁移失败
# 查看配置文件备份
$ sudo ls -la /var/log/leapp/*.rpmsave

# 手动恢复配置文件
$ sudo cp /var/log/leapp/ssh_config.rpmsave /etc/ssh/ssh_config

# 重启相关服务
$ sudo systemctl restart sshd

# 问题5:网络连接失败
# 检查网络接口
$ ip addr show

# 检查网络配置
$ cat /etc/sysconfig/network-scripts/ifcfg-ens33

# 重启网络服务
$ sudo systemctl restart NetworkManager

# 验证网络连接
$ ping -c 4 8.8.8.8

# 问题6:SELinux问题
# 检查SELinux状态
$ getenforce

# 查看SELinux日志
$ sudo ausearch -m avc -ts recent

# 临时禁用SELinux
$ sudo setenforce 0

# 永久禁用SELinux(不推荐)
$ sudo vi /etc/selinux/config
SELINUX=permissive

故障排查要点:1. 查看升级日志;2. 查看系统日志;3. 检查网络连接;4. 检查磁盘空间;5. 检查SELinux状态;6. 检查防火墙配置;7. 查看GRUB配置;8. 检查系统服务。

10. 风哥经验总结

在生产环境中进行RHEL9到RHEL10升级的经验总结。学习交流加群风哥微信: itpux-com

# 经验1:充分的前期准备
$ cat > /backup/upgrade_experience1.txt << 'EOF' 经验1:充分的前期准备是升级成功的关键 1. 系统检查要全面 - 不要只依赖leapp preupgrade - 手动检查重要配置 - 验证所有依赖关系 2. 问题修复要彻底 - 不要跳过任何警告 - 高优先级问题必须修复 - 中等优先级问题尽量修复 3. 备份要完整 - 系统配置文件 - 重要数据 - 数据库 - 软件包列表 - 系统信息 4. 测试要充分 - 在测试环境先验证 - 验证升级流程 - 验证回滚流程 - 验证应用兼容性 EOF
# 经验2:选择合适的升级时机
$ cat > /backup/upgrade_experience2.txt << 'EOF' 经验2:选择合适的升级时机 1. 避开业务高峰期 - 选择业务低峰期 - 安排充足的维护窗口 - 通知所有相关人员 2. 考虑节假日 - 避开重要节假日 - 避开月初月末 - 避开季度末年末 3. 准备应急预案 - 升级失败的处理方案 - 回滚流程 - 紧急联系方式 - 技术支持渠道 EOF
# 经验3:升级过程监控
$ cat > /backup/upgrade_experience3.txt << 'EOF' 经验3:升级过程要密切监控 1. 实时监控升级进度 - 关注升级日志 - 监控系统资源 - 检查错误信息 2. 及时处理问题 - 不要忽略任何错误 - 及时记录问题 - 快速寻找解决方案 3. 保持沟通 - 及时向相关人员汇报进度 - 遇到问题及时沟通 - 寻求技术支持 EOF
风哥提示:leapp工具是RHEL9到RHEL10原位升级的标准工具,通过充分的前期准备、详细的计划、严格的执行和全面的验证,可以大大提高升级成功的概率。

总结:leapp工具提供了从RHEL9到RHEL10的原位升级能力。通过leapp preupgrade检查、问题修复、leapp upgrade执行和升级后验证,可以安全地完成系统升级。在生产环境中升级前,务必在测试环境中充分验证。

本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html

联系我们

在线咨询:点击这里给我发消息

微信号:itpux-com

工作日:9:30-18:30,节假日休息