迁移 CentOS7 到 RockyLinux8 的实战方案

作者:Administrator 发布时间: 2025-10-01 阅读量:15

1、将centos7系统更新到最新版本

# 更新系统
[root@localhost ~]# yum update -y && yum upgrade -y 

# 更新完成后重启
[root@localhost ~]# reboot

# 检查系统版本和内核版本
[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

[root@localhost ~]# uname -r
3.10.0-1160.119.1.el7.x86_64

2、Install Elevate

2.1 安装 Elevate 提升存储库

yum install -y https://repo.almalinux.org/elevate/elevate-release-latest-el7.noarch.rpm

0ba05de1-43b7-42fa-962f-90648707ec43.png

2.2 安装 Leapp 和迁移数据

因为 Elevate 在后台使用 Leapp,所以我们需要安装相应的包:

#rockylinux 安装包
yum install -y leapp-upgrade leapp-data-rocky

如果您想迁移到其他发行版之一,请将“leapp-data-rocky”包替换为其一:

  • leapp-data-almalinux

  • leapp-data-oraclelinux

  • leapp-data-rocky

3、升级前检查

[root@localhost ~]# leapp preupgrade
......
============================================================
                     UPGRADE INHIBITED                      
============================================================

Upgrade has been inhibited due to the following problems:
    1. Inhibitor: Use of NFS detected. Upgrade can't proceed
    2. Inhibitor: Missing required answers in the answer file
Consult the pre-upgrade report for details and possible remediation.

============================================================
                     UPGRADE INHIBITED                      
============================================================


Debug output written to /var/log/leapp/leapp-preupgrade.log

============================================================
                           REPORT                           
============================================================

A report has been generated at /var/log/leapp/leapp-report.json
A report has been generated at /var/log/leapp/leapp-report.txt

============================================================
                       END OF REPORT                        
============================================================

Answerfile has been generated at /var/log/leapp/answerfile

9a625247-4ddc-49ee-9a18-41d2ff2e11e2.png

2.4 查看检查可能的问题并根据推荐的解决方案修复

查看生成的响应文件和报告,内容提到了您需要解决的任何问题。这是我必须做的:

[root@localhost ~]# cat /var/log/leapp/leapp-report.txt

rmmod pata_acpi
echo PermitRootLogin yes | sudo tee -a /etc/ssh/sshd_config
leapp answer --section remove_pam_pkcs11_module_check.confirm=True


# 根据提示,关闭服务,卸载软件
yum remove nfs-utils

#清理所有无用软件包
[root@localhost html]# package-cleanup --leaves
Loaded plugins: fastestmirror
libnfsidmap-0.25-19.el7.x86_64
libsysfs-2.1.0-16.el7.x86_64

# 根据提示,卸载软件
yum remove $(package-cleanup --leaves)


#清理RPM软件包
[root@localhost ~]# package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
nginx-release-centos-7-0.el7.ngx.noarch

#删除需要清理的包
yum remove $(package-cleanup --orphans)


#清理所有无用软件包
modprobe -r pata_acpi
modprobe -r mptspi
modprobe -r mptscsih
modprobe -r mptbase


#清理旧的内核版本,只保留最新的1个内核版本
package-cleanup --oldkernels --count=1

4、Upgrade to Rocky Linux 8

解决所有问题后,执行如下命令,将 CentOS 7 迁移到 RockyLinux 8

[root@localhost ~]# leapp upgrade

8d9b0cc5-ae85-4f05-9cb3-b638ce919ba7.png

[root@localhost ~]# reboot

在重新启动过程中,将出现一个标有“Elevate-Upgrade-Initramfs”的新引导选项,如下图:

63e7dc83-fb4d-4568-a735-3aad0c1abdc1.png

默认选择第一项,将自动升级系统所有包,同时也会进行软件包的校验。

daadc45b-ddd4-480f-bc9a-1cf8c422e87f.png

f2b794b7-a5e3-4a23-8bdc-771af2b5148e.png

如果系统所有软件包升级和校验成功后,将会自动重启系统。

01275bbc-6549-49a3-803d-6d2c111d50ef.png

自检成功后,会再次自动重启系统。

系统启动成功后,显示如下:

1f051816-7afb-451b-be22-82666c46b0b4.png

5、登录后,请验证操作系统版本信息

[root@localhost ~]# cat /etc/redhat-release 
Rocky Linux release 8.10 (Green Obsidian)
[root@localhost ~]# 
[root@localhost ~]# uname -r
4.18.0-553.5.1.el8_10.x86_64