【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2

2024年 8月 1日 96.3k 0

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-1

概述

前文(《 
【PG16】 后 RHEL 7 时代, PG 16 如何在 CentOS 7 上运行 
 》) 说到,PG16 已经对 CentOS 7 停止支持,不再提供相应的 RPM 包,或许也是时候考虑将 CentOS 7 系统进行升级了。

本文将演示如何将 CentOS 7.9 升级到 Rocky Linux 9.2。

由于某些不可控因素,无法从 CentOS 7.9 直接升级到 Rocky Linux 9.2,而是选择这样一个路径:

CentOS 7.9 --> CentOS 8.5 --> Rocky Linux 8.8 --> Rocky Linux 9.2

检查

检查系统 Kernel 及 OS 版本。

uname -r
cat /etc/redhat-release

输出日志:

[root@shawnyan ~]# uname -r
3.10.0-1160.95.1.el7.x86_64
[root@shawnyan ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

安装 dnf

从 RHEL 8 开始,系统默认安装并使用 dnf 作为包管理器,这里先安装 dnf,以替代 yum。

yum install dnf -y
dnf --version

输出日志:

[root@shawnyan ~]# yum install dnf -y
Loaded plugins: fastestmirror, langpacks
...
Dependencies Resolved
============================================================================================================================================================================================================================================
Package                                                     Arch                                              Version                                                      Repository                                                 Size
============================================================================================================================================================================================================================================
Installing:
dnf                                                         noarch                                            4.0.9.2-2.el7_9                                              extras-aliyun                                             357 k
Installing for dependencies:
dnf-data                                                    noarch                                            4.0.9.2-2.el7_9                                              extras-aliyun                                              51 k
libcomps                                                    x86_64                                            0.1.8-14.el7                                                 extras-aliyun                                              75 k
libdnf                                                      x86_64                                            0.22.5-2.el7_9                                               extras-aliyun                                             535 k
libmodulemd                                                 x86_64                                            1.6.3-1.el7                                                  extras-aliyun                                             141 k
librepo                                                     x86_64                                            1.8.1-8.el7_9                                                updates-aliyun                                             82 k
libsolv                                                     x86_64                                            0.6.34-4.el7                                                 base-aliyun                                               329 k
python2-dnf                                                 noarch                                            4.0.9.2-2.el7_9                                              extras-aliyun                                             414 k
python2-hawkey                                              x86_64                                            0.22.5-2.el7_9                                               extras-aliyun                                              71 k
python2-libcomps                                            x86_64                                            0.1.8-14.el7                                                 extras-aliyun                                              47 k
python2-libdnf                                              x86_64                                            0.22.5-2.el7_9                                               extras-aliyun                                             611 k
Transaction Summary
============================================================================================================================================================================================================================================
Install  1 Package (+10 Dependent packages)
Total download size: 2.6 M
Installed size: 10 M
Downloading packages:
(1/11): dnf-data-4.0.9.2-2.el7_9.noarch.rpm                                                                                                                                                                          |  51 kB  00:00:00     
(2/11): dnf-4.0.9.2-2.el7_9.noarch.rpm                                                                                                                                                                               | 357 kB  00:00:00     
(3/11): libcomps-0.1.8-14.el7.x86_64.rpm                                                                                                                                                                             |  75 kB  00:00:00     
(4/11): libmodulemd-1.6.3-1.el7.x86_64.rpm                                                                                                                                                                           | 141 kB  00:00:00     
(5/11): libdnf-0.22.5-2.el7_9.x86_64.rpm                                                                                                                                                                             | 535 kB  00:00:00     
(6/11): librepo-1.8.1-8.el7_9.x86_64.rpm                                                                                                                                                                             |  82 kB  00:00:00     
(7/11): python2-hawkey-0.22.5-2.el7_9.x86_64.rpm                                                                                                                                                                     |  71 kB  00:00:00     
(8/11): python2-dnf-4.0.9.2-2.el7_9.noarch.rpm                                                                                                                                                                       | 414 kB  00:00:00     
(9/11): python2-libcomps-0.1.8-14.el7.x86_64.rpm                                                                                                                                                                     |  47 kB  00:00:00     
(10/11): libsolv-0.6.34-4.el7.x86_64.rpm                                                                                                                                                                             | 329 kB  00:00:00     
(11/11): python2-libdnf-0.22.5-2.el7_9.x86_64.rpm                                                                                                                                                                    | 611 kB  00:00:00     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       1.2 MB/s | 2.6 MB  00:00:02     
...
[root@shawnyan ~]# dnf --version
4.0.9
  Installed: dnf-0:4.0.9.2-2.el7_9.noarch at Thu 05 Oct 2023 02:54:34 PM CST
  Built    : CentOS BuildSystem <http://bugs.centos.org> at Wed 07 Apr 2021 03:52:38 PM CST
  Installed: rpm-0:4.11.3-48.el7_9.x86_64 at Fri 10 Feb 2023 02:11:48 PM CST
  Built    : CentOS BuildSystem <http://bugs.centos.org> at Wed 24 Nov 2021 04:33:39 PM CST
[root@shawnyan ~]#

检查包冲突,并卸载冲突的包

在升级之前,需要先解决包冲突的问题,不然升级过程中会遇到报错。这一步也是在后续整理文章时加入的。

具体命令如下:

yum install -y yum-utils rpmconf
rpmconf -a
package-cleanup --leaves
package-cleanup --orphans
yum remove -y <package>

输出日志:

[root@shawnyan ~]# dnf install yum-utils
Last metadata expiration check: 0:02:42 ago on Sun 15 Oct 2023 02:32:45 PM CST.
Dependencies resolved.
============================================================================================================================================================================================================================================
Package                                                           Arch                                            Version                                                       Repository                                            Size
============================================================================================================================================================================================================================================
Installing:
yum-utils                                                         noarch                                          1.1.31-54.el7_8                                               base-aliyun                                          122 k
Installing dependencies:
yum                                                               noarch                                          3.4.3-168.el7.centos                                          base-aliyun                                          1.2 M
yum-metadata-parser                                               x86_64                                          1.1.4-10.el7                                                  base-aliyun                                           28 k
yum-plugin-fastestmirror                                          noarch                                          1.1.31-54.el7_8                                               base-aliyun                                           34 k
Transaction Summary
============================================================================================================================================================================================================================================
Install  4 Packages
Total download size: 1.4 M
Installed size: 6.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm                                                                                                                                                   84 kB/s |  34 kB     00:00    
(2/4): yum-metadata-parser-1.1.4-10.el7.x86_64.rpm                                                                                                                                                           54 kB/s |  28 kB     00:00    
(3/4): yum-utils-1.1.31-54.el7_8.noarch.rpm                                                                                                                                                                 543 kB/s | 122 kB     00:00    
(4/4): yum-3.4.3-168.el7.centos.noarch.rpm                                                                                                                                                                  899 kB/s | 1.2 MB     00:01    
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       1.0 MB/s | 1.4 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                    1/1
  Installing       : yum-metadata-parser-1.1.4-10.el7.x86_64                                                                                                                                                                            1/4
  Installing       : yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch                                                                                                                                                                    2/4
  Installing       : yum-3.4.3-168.el7.centos.noarch                                                                                                                                                                                    3/4
  Installing       : yum-utils-1.1.31-54.el7_8.noarch                                                                                                                                                                                   4/4
  Verifying        : yum-3.4.3-168.el7.centos.noarch                                                                                                                                                                                    1/4
  Verifying        : yum-metadata-parser-1.1.4-10.el7.x86_64                                                                                                                                                                            2/4
  Verifying        : yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch                                                                                                                                                                    3/4
  Verifying        : yum-utils-1.1.31-54.el7_8.noarch                                                                                                                                                                                   4/4
Installed:
  yum-utils-1.1.31-54.el7_8.noarch                     yum-3.4.3-168.el7.centos.noarch                     yum-metadata-parser-1.1.4-10.el7.x86_64                     yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch                    
Complete!

卸载 yum

确认没有包冲突之后,就可以卸载 yum 了,之后就完全使用 dnf 作为替代。

dnf remove -y yum*
rm -Rf /etc/yum

输出日志:

[root@shawnyan ~]# dnf remove -y yum*
Dependencies resolved.
============================================================================================================================================================================================================================================
Package                                                            Arch                                           Version                                                            Repository                                       Size
============================================================================================================================================================================================================================================
Removing:
yum                                                                noarch                                         3.4.3-168.el7.centos                                               @System                                         5.6 M
yum-langpacks                                                      noarch                                         0.4.2-7.el7                                                        @System                                          71 k
yum-metadata-parser                                                x86_64                                         1.1.4-10.el7                                                       @System                                          57 k
yum-plugin-fastestmirror                                           noarch                                         1.1.31-54.el7_8                                                    @System                                          53 k
yum-utils                                                          noarch                                         1.1.31-54.el7_8                                                    @System                                         337 k
Removing dependent packages:
firstboot                                                          x86_64                                         19.12-1.el7                                                        @System                                         294 k
gnome-packagekit                                                   x86_64                                         3.28.0-1.el7                                                       @System                                           0  
gnome-software                                                     x86_64                                         3.28.2-3.el7                                                       @System                                         8.4 M
initial-setup-gui                                                  x86_64                                         0.3.9.45-1.el7.centos                                              @System                                          32 k
Removing unused dependencies:
PackageKit                                                         x86_64                                         1.1.10-2.el7.centos                                                @System                                         2.6 M
PackageKit-yum                                                     x86_64                                         1.1.10-2.el7.centos                                                @System                                         301 k
anaconda-core                                                      x86_64                                         21.48.22.159-1.el7.centos                                          @System                                         8.2 M
anaconda-gui                                                       x86_64                                         21.48.22.159-1.el7.centos                                          @System                                         1.5 M
anaconda-tui                                                       x86_64                                         21.48.22.159-1.el7.centos                                          @System                                         447 k
createrepo                                                         noarch                                         0.9.9-28.el7                                                       @System                                         302 k
gnome-packagekit-common                                            x86_64                                         3.28.0-1.el7                                                       @System                                         6.4 M
gnome-packagekit-installer                                         x86_64                                         3.28.0-1.el7                                                       @System                                         202 k
gnome-packagekit-updater                                           x86_64                                         3.28.0-1.el7                                                       @System                                         194 k
initial-setup                                                      x86_64                                         0.3.9.45-1.el7.centos                                              @System                                         222 k
python-meh                                                         noarch                                         0.25.3-1.el7                                                       @System                                         254 k
python-meh-gui                                                     noarch                                         0.25.3-1.el7                                                       @System                                          24 k
Transaction Summary
============================================================================================================================================================================================================================================
Remove  21 Packages
Freed space: 35 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                    1/1
  Running scriptlet: initial-setup-gui-0.3.9.45-1.el7.centos.x86_64                                                                                                                                                                    1/21
  Erasing          : initial-setup-gui-0.3.9.45-1.el7.centos.x86_64                                                                                                                                                                    1/21
  Running scriptlet: initial-setup-gui-0.3.9.45-1.el7.centos.x86_64                                                                                                                                                                    1/21
  Erasing          : anaconda-gui-21.48.22.159-1.el7.centos.x86_64                                                                                                                                                                     2/21
  Erasing          : gnome-packagekit-3.28.0-1.el7.x86_64                                                                                                                                                                              3/21
  Running scriptlet: gnome-packagekit-3.28.0-1.el7.x86_64                                                                                                                                                                              3/21
  Erasing          : python-meh-gui-0.25.3-1.el7.noarch                                                                                                                                                                                4/21
  Running scriptlet: initial-setup-0.3.9.45-1.el7.centos.x86_64                                                                                                                                                                        5/21
  Erasing          : initial-setup-0.3.9.45-1.el7.centos.x86_64                                                                                                                                                                        5/21
  Running scriptlet: initial-setup-0.3.9.45-1.el7.centos.x86_64                                                                                                                                                                        5/21
  Erasing          : anaconda-tui-21.48.22.159-1.el7.centos.x86_64                                                                                                                                                                     6/21
  Erasing          : anaconda-core-21.48.22.159-1.el7.centos.x86_64                                                                                                                                                                    7/21
  Erasing          : createrepo-0.9.9-28.el7.noarch                                                                                                                                                                                    8/21
  Erasing          : yum-utils-1.1.31-54.el7_8.noarch                                                                                                                                                                                  9/21
  Erasing          : yum-langpacks-0.4.2-7.el7.noarch                                                                                                                                                                                 10/21
warning: /etc/yum/pluginconf.d/langpacks.conf saved as /etc/yum/pluginconf.d/langpacks.conf.rpmsave
  Running scriptlet: firstboot-19.12-1.el7.x86_64                                                                                                                                                                                     11/21
  Erasing          : firstboot-19.12-1.el7.x86_64                                                                                                                                                                                     11/21
  Running scriptlet: firstboot-19.12-1.el7.x86_64                                                                                                                                                                                     11/21
  Erasing          : python-meh-0.25.3-1.el7.noarch                                                                                                                                                                                   12/21
  Erasing          : gnome-packagekit-installer-3.28.0-1.el7.x86_64                                                                                                                                                                   13/21
  Erasing          : gnome-packagekit-updater-3.28.0-1.el7.x86_64                                                                                                                                                                     14/21
  Erasing          : gnome-packagekit-common-3.28.0-1.el7.x86_64                                                                                                                                                                      15/21
  Erasing          : gnome-software-3.28.2-3.el7.x86_64                                                                                                                                                                               16/21
  Running scriptlet: gnome-software-3.28.2-3.el7.x86_64                                                                                                                                                                               16/21
  Erasing          : PackageKit-yum-1.1.10-2.el7.centos.x86_64                                                                                                                                                                        17/21
  Erasing          : PackageKit-1.1.10-2.el7.centos.x86_64                                                                                                                                                                            18/21
  Erasing          : yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch                                                                                                                                                                  19/21
  Erasing          : yum-3.4.3-168.el7.centos.noarch                                                                                                                                                                                  20/21
  Erasing          : yum-metadata-parser-1.1.4-10.el7.x86_64                                                                                                                                                                          21/21
  Verifying        : PackageKit-1.1.10-2.el7.centos.x86_64                                                                                                                                                                             1/21
  Verifying        : PackageKit-yum-1.1.10-2.el7.centos.x86_64                                                                                                                                                                         2/21
  Verifying        : anaconda-core-21.48.22.159-1.el7.centos.x86_64                                                                                                                                                                    3/21
  Verifying        : anaconda-gui-21.48.22.159-1.el7.centos.x86_64                                                                                                                                                                     4/21
  Verifying        : anaconda-tui-21.48.22.159-1.el7.centos.x86_64                                                                                                                                                                     5/21
  Verifying        : createrepo-0.9.9-28.el7.noarch                                                                                                                                                                                    6/21
  Verifying        : firstboot-19.12-1.el7.x86_64                                                                                                                                                                                      7/21
  Verifying        : gnome-packagekit-3.28.0-1.el7.x86_64                                                                                                                                                                              8/21
  Verifying        : gnome-packagekit-common-3.28.0-1.el7.x86_64                                                                                                                                                                       9/21
  Verifying        : gnome-packagekit-installer-3.28.0-1.el7.x86_64                                                                                                                                                                   10/21
  Verifying        : gnome-packagekit-updater-3.28.0-1.el7.x86_64                                                                                                                                                                     11/21
  Verifying        : gnome-software-3.28.2-3.el7.x86_64                                                                                                                                                                               12/21
  Verifying        : initial-setup-0.3.9.45-1.el7.centos.x86_64                                                                                                                                                                       13/21
  Verifying        : initial-setup-gui-0.3.9.45-1.el7.centos.x86_64                                                                                                                                                                   14/21
  Verifying        : python-meh-0.25.3-1.el7.noarch                                                                                                                                                                                   15/21
  Verifying        : python-meh-gui-0.25.3-1.el7.noarch                                                                                                                                                                               16/21
  Verifying        : yum-3.4.3-168.el7.centos.noarch                                                                                                                                                                                  17/21
  Verifying        : yum-langpacks-0.4.2-7.el7.noarch                                                                                                                                                                                 18/21
  Verifying        : yum-metadata-parser-1.1.4-10.el7.x86_64                                                                                                                                                                          19/21
  Verifying        : yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch                                                                                                                                                                  20/21
  Verifying        : yum-utils-1.1.31-54.el7_8.noarch                                                                                                                                                                                 21/21
Removed:
  yum-3.4.3-168.el7.centos.noarch               yum-langpacks-0.4.2-7.el7.noarch                 yum-metadata-parser-1.1.4-10.el7.x86_64         yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch   yum-utils-1.1.31-54.el7_8.noarch       
  firstboot-19.12-1.el7.x86_64                  gnome-packagekit-3.28.0-1.el7.x86_64             gnome-software-3.28.2-3.el7.x86_64              initial-setup-gui-0.3.9.45-1.el7.centos.x86_64    PackageKit-1.1.10-2.el7.centos.x86_64  
  PackageKit-yum-1.1.10-2.el7.centos.x86_64     anaconda-core-21.48.22.159-1.el7.centos.x86_64   anaconda-gui-21.48.22.159-1.el7.centos.x86_64   anaconda-tui-21.48.22.159-1.el7.centos.x86_64     createrepo-0.9.9-28.el7.noarch         
  gnome-packagekit-common-3.28.0-1.el7.x86_64   gnome-packagekit-installer-3.28.0-1.el7.x86_64   gnome-packagekit-updater-3.28.0-1.el7.x86_64    initial-setup-0.3.9.45-1.el7.centos.x86_64        python-meh-0.25.3-1.el7.noarch         
  python-meh-gui-0.25.3-1.el7.noarch           
Complete!
[root@shawnyan ~]# rm -Rf /etc/yum
[root@shawnyan ~]#

切换 yum 源到 Rocky Linux 8,并升级 – FAILED

将现有的 yum 源文件进行备份,并上传 Rocky Linux 8 的仓库文件。

cd /etc/yum.repos.d
mkdir el7
mv *.repo el7
vi rocky.repo

然后执行升级命令。

dnf upgrade

不过这样从 CentOS 7 直接升级到 Rocky Linux 8 总是报错,尚未找到合适的解决办法。

Running transaction check
Error: transaction check vs depsolve:
(gcc >= 8 with gcc < 9) is needed by annobin-10.94-1.el8.x86_64
rpmlib(RichDependencies) <= 4.12.0-1 is needed by annobin-10.94-1.el8.x86_64
(flatpak-selinux = 1.10.7-1.el8 if selinux-policy-targeted) is needed by flatpak-1.10.7-1.el8.x86_64
rpmlib(RichDependencies) <= 4.12.0-1 is needed by flatpak-1.10.7-1.el8.x86_64
(annobin if gcc) is needed by redhat-rpm-config-131-1.el8.noarch
(gcc-plugin-annobin if gcc) is needed by redhat-rpm-config-131-1.el8.noarch
rpmlib(RichDependencies) <= 4.12.0-1 is needed by redhat-rpm-config-131-1.el8.noarch
(NetworkManager >= 1.20 or dhclient) is needed by dracut-network-049-223.git20230119.el8.x86_64
rpmlib(RichDependencies) <= 4.12.0-1 is needed by dracut-network-049-223.git20230119.el8.x86_64
(selinux-policy >= 3.14.3-98 if selinux-policy) is needed by rng-tools-6.15-3.el8.x86_64
rpmlib(RichDependencies) <= 4.12.0-1 is needed by rng-tools-6.15-3.el8.x86_64
(systemd-standalone-tmpfiles or systemd) is needed by samba-common-0:4.17.5-3.el8_8.noarch
rpmlib(RichDependencies) <= 4.12.0-1 is needed by samba-common-0:4.17.5-3.el8_8.noarch
To diagnose the problem, try running: 'rpm -Va --nofiles --nodigest'.
You probably have corrupted RPMDB, running 'rpm --rebuilddb' might fix the issue.
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.

无奈只好采取迂回战略,先从 CentOS 7 升级到 CentOS 8,再迁移到 Rocky Linux。

切换 yum 源到 CentOS Vault 8.5 – SUCCESS

将 yum 源切换到 CentOS Vault 8.5。

vi centos8.repo

测试 yum 源是否可以正常使用。

dnf group list

输出结果:

[root@shawnyan yum.repos.d]# dnf group list
AppStream-Aliyun                                                                                                                                                                                            8.6 MB/s |  11 MB     00:01    
BaseOS-Aliyun                                                                                                                                                                                               7.0 MB/s | 7.1 MB     00:01    
epel-aliyun                                                                                                                                                                                                 9.3 MB/s |  16 MB     00:01    
Last metadata expiration check: 0:00:02 ago on Thu 05 Oct 2023 10:56:02 PM CST.

关键步骤来了,从 CentOS 7 升级到 CentOS 8。

使用 
dnf distro-sync 命令,将系统中已安装的软件包同步到最新版本。

rpm --rebuilddb
# 移除旧 CentOS kernel
rpm -e `rpm -q kernel` --nodeps
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync --disablerepo=AppStream --best

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-2

升级日志太多,此处省略一万字。。。

...
  Cleanup          : setup-2.8.71-11.el7.noarch                                               1812/1816
  Obsoleting       : centos-release-7-9.2009.1.el7.centos.x86_64                              1813/1816
  Cleanup          : ncurses-base-5.9-14.20130511.el7_4.noarch                                1815/1816
  Cleanup          : libgcc-4.8.5-44.el7.x86_64                                               1816/1816
  Running scriptlet: libgcc-4.8.5-44.el7.x86_64                                               1816/1816
  Running scriptlet: filesystem-3.8-6.el8.x86_64                                              1816/1816
  Running scriptlet: glibc-all-langpacks-2.28-164.el8.x86_64                                  1816/1816
  Running scriptlet: ca-certificates-2021.2.50-80.0.el8_4.noarch                              1816/1816
  Running scriptlet: GeoIP-GeoLite-data-2018.06-5.el8.noarch                                  1816/1816
  Running scriptlet: authselect-libs-1.2.2-3.el8.x86_64                                       1816/1816
  Running scriptlet: kernel-core-4.18.0-348.7.1.el8_5.x86_64                                  1816/1816
...
Complete!

升级完成后,查看系统版本,可以看到已经升级到了 CentOS 8.5,但是内核版本还停留在 el7,需要重启系统。

[root@shawnyan ~]# uname -r
3.10.0-1160.95.1.el7.x86_64
[root@shawnyan ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@shawnyan yum.repos.d]# hostnamectl
   Static hostname: shawnyan
         Icon name: computer-vm
           Chassis: vm
        Machine ID: e7f51860c9c34455bcb755eac18c8868
           Boot ID: 9558aec7c722488da9388e251df4ebbf
    Virtualization: vmware
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 3.10.0-1160.95.1.el7.x86_64
      Architecture: x86-64
[root@shawnyan yum.repos.d]# reboot

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-2

重启之后,可以看到版本都升级到 el8 了。

Last login: Tue Oct 24 23:59:50 2023 from 192.168.8.1
[root@shawnyan ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@shawnyan ~]# uname -a
Linux shawnyan 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@shawnyan ~]# hostnamectl
   Static hostname: shawnyan
         Icon name: computer-vm
           Chassis: vm
        Machine ID: e7f51860c9c34455bcb755eac18c8868
           Boot ID: 56c5f6e4c9a0497db3654cf0d4b48541
    Virtualization: vmware
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-348.7.1.el8_5.x86_64
      Architecture: x86-64
[root@shawnyan ~]#

从 CentOS 8 切换到 Rocky 8

从 CentOS 切换到 Rocky,需要先切换 yum 源,然后执行 
dnf swap 切换命令即可。

dnf swap 'centos-*' rocky-release

输出日志:

[root@shawnyan yum.repos.d]# dnf swap 'centos-*' rocky-release
epel-aliyun                                                                                                                                                                                                 1.3 MB/s |  16 MB     00:12    
BaseOS-Aliyun                                                                                                                                                                                               1.9 MB/s | 7.2 MB     00:03    
AppStream-Aliyun                                                                                                                                                                                            1.3 MB/s |  12 MB     00:08    
Last metadata expiration check: 0:00:01 ago on Wed 25 Oct 2023 12:42:08 AM CST.
Dependencies resolved.
============================================================================================================================================================================================================================================
Package                                                         Architecture                                     Version                                                     Repository                                               Size
============================================================================================================================================================================================================================================
Installing:
rocky-release                                                   noarch                                           8.8-1.8.el8                                                 BaseOS-Aliyun                                            22 k
Installing dependencies:
rocky-gpg-keys                                                  noarch                                           8.8-1.8.el8                                                 BaseOS-Aliyun                                            13 k
rocky-repos                                                     noarch                                           8.8-1.8.el8                                                 BaseOS-Aliyun                                            15 k
Removing:
centos-gpg-keys                                                 noarch                                           1:8-3.el8                                                   @base                                                   3.3 k
centos-indexhtml                                                noarch                                           8.0-0.el8                                                   @base                                                   505 k
centos-linux-release                                            noarch                                           8.5-1.2111.el8                                              @base                                                    26 k
centos-linux-repos                                              noarch                                           8-3.el8                                                     @base                                                    26 k
centos-logos                                                    x86_64                                           85.8-2.el8                                                  @base                                                   716 k
centos-release-scl                                              noarch                                           2-3.el7.centos                                              @System                                                  20 k
centos-release-scl-rh                                           noarch                                           2-3.el7.centos                                              @System                                                  20 k
Transaction Summary
============================================================================================================================================================================================================================================
Install  3 Packages
Remove   7 Packages
Total download size: 50 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): rocky-gpg-keys-8.8-1.8.el8.noarch.rpm                                                                                                                                                                 68 kB/s |  13 kB     00:00    
(2/3): rocky-release-8.8-1.8.el8.noarch.rpm                                                                                                                                                                 107 kB/s |  22 kB     00:00    
(3/3): rocky-repos-8.8-1.8.el8.noarch.rpm                                                                                                                                                                    62 kB/s |  15 kB     00:00    
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       202 kB/s |  50 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                    1/1
  Running scriptlet: rocky-gpg-keys-8.8-1.8.el8.noarch                                                                                                                                                                                  1/1
  Installing       : rocky-gpg-keys-8.8-1.8.el8.noarch                                                                                                                                                                                 1/10
  Installing       : rocky-release-8.8-1.8.el8.noarch                                                                                                                                                                                  2/10
  Installing       : rocky-repos-8.8-1.8.el8.noarch                                                                                                                                                                                    3/10
  Erasing          : centos-release-scl-2-3.el7.centos.noarch                                                                                                                                                                          4/10
warning: file /etc/yum.repos.d/CentOS-SCLo-scl.repo: remove failed: No such file or directory
  Erasing          : centos-release-scl-rh-2-3.el7.centos.noarch                                                                                                                                                                       5/10
warning: file /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo: remove failed: No such file or directory
  Erasing          : centos-linux-release-8.5-1.2111.el8.noarch                                                                                                                                                                        6/10
  Erasing          : centos-linux-repos-8-3.el8.noarch                                                                                                                                                                                 7/10
warning: file /etc/yum.repos.d/CentOS-Linux-Sources.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-PowerTools.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-Plus.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-Media.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-HighAvailability.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-FastTrack.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-Extras.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-Devel.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-Debuginfo.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-ContinuousRelease.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-BaseOS.repo: remove failed: No such file or directory
warning: file /etc/yum.repos.d/CentOS-Linux-AppStream.repo: remove failed: No such file or directory
  Erasing          : centos-gpg-keys-1:8-3.el8.noarch                                                                                                                                                                                  8/10
  Erasing          : centos-logos-85.8-2.el8.x86_64                                                                                                                                                                                    9/10
  Running scriptlet: centos-logos-85.8-2.el8.x86_64                                                                                                                                                                                    9/10
  Erasing          : centos-indexhtml-8.0-0.el8.noarch                                                                                                                                                                                10/10
  Running scriptlet: centos-indexhtml-8.0-0.el8.noarch                                                                                                                                                                                10/10
  Verifying        : rocky-gpg-keys-8.8-1.8.el8.noarch                                                                                                                                                                                 1/10
  Verifying        : rocky-release-8.8-1.8.el8.noarch                                                                                                                                                                                  2/10
  Verifying        : rocky-repos-8.8-1.8.el8.noarch                                                                                                                                                                                    3/10
  Verifying        : centos-gpg-keys-1:8-3.el8.noarch                                                                                                                                                                                  4/10
  Verifying        : centos-indexhtml-8.0-0.el8.noarch                                                                                                                                                                                 5/10
  Verifying        : centos-linux-release-8.5-1.2111.el8.noarch                                                                                                                                                                        6/10
  Verifying        : centos-linux-repos-8-3.el8.noarch                                                                                                                                                                                 7/10
  Verifying        : centos-logos-85.8-2.el8.x86_64                                                                                                                                                                                    8/10
  Verifying        : centos-release-scl-2-3.el7.centos.noarch                                                                                                                                                                          9/10
  Verifying        : centos-release-scl-rh-2-3.el7.centos.noarch                                                                                                                                                                      10/10
Installed:
  rocky-gpg-keys-8.8-1.8.el8.noarch                                              rocky-release-8.8-1.8.el8.noarch                                              rocky-repos-8.8-1.8.el8.noarch                                             
Removed:
  centos-gpg-keys-1:8-3.el8.noarch             centos-indexhtml-8.0-0.el8.noarch  centos-linux-release-8.5-1.2111.el8.noarch  centos-linux-repos-8-3.el8.noarch  centos-logos-85.8-2.el8.x86_64  centos-release-scl-2-3.el7.centos.noarch
  centos-release-scl-rh-2-3.el7.centos.noarch
Complete!
[root@shawnyan yum.repos.d]#
[root@shawnyan yum.repos.d]#
[root@shawnyan yum.repos.d]#
[root@shawnyan yum.repos.d]# cat /etc/redhat-release
Rocky Linux release 8.8 (Green Obsidian)
[root@shawnyan yum.repos.d]# uname -a
Linux shawnyan 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@shawnyan yum.repos.d]# hostnamectl
   Static hostname: shawnyan
         Icon name: computer-vm
           Chassis: vm
        Machine ID: e7f51860c9c34455bcb755eac18c8868
           Boot ID: 56c5f6e4c9a0497db3654cf0d4b48541
    Virtualization: vmware
  Operating System: Rocky Linux 8.8 (Green Obsidian)
       CPE OS Name: cpe:/o:rocky:rocky:8:GA
            Kernel: Linux 4.18.0-348.7.1.el8_5.x86_64
      Architecture: x86-64
[root@shawnyan yum.repos.d]#

切换很顺畅,完成后再执行升级,将系统内核更新到最新版本。

[root@shawnyan yum.repos.d]# dnf update --allowerasing
...
Installed:
  NetworkManager-initscripts-updown-1:1.40.16-4.el8_8.noarch annobin-10.94-1.el8.x86_64                bind-libs-32:9.11.36-8.el8_8.2.x86_64  bind-libs-lite-32:9.11.36-8.el8_8.2.x86_64 bind-utils-32:9.11.36-8.el8_8.2.x86_64         
  elfutils-libelf-devel-0.188-3.el8.x86_64                   fstrm-0.6.1-3.el8.x86_64                  gcc-8.5.0-18.el8.x86_64                gcc-plugin-annobin-8.5.0-18.el8.x86_64     geolite2-city-20180605-1.el8.noarch            
  geolite2-country-20180605-1.el8.noarch                     glibc-gconv-extra-2.28-225.el8_8.6.x86_64 isl-0.16.1-6.el8.x86_64                kernel-core-4.18.0-477.27.1.el8_8.x86_64   kernel-debug-devel-4.18.0-477.27.1.el8_8.x86_64
  kernel-modules-4.18.0-477.27.1.el8_8.x86_64                libmaxminddb-1.2.0-10.el8.x86_64          protobuf-c-1.3.0-6.el8.x86_64          python3-bind-32:9.11.36-8.el8_8.2.noarch   python3-chardet-3.0.4-7.el8.noarch             
  python3-idna-2.5-5.el8.noarch                              python3-magic-5.33-24.el8.noarch          python3-pexpect-4.3.1-3.el8.noarch     python3-ply-3.9-9.el8.noarch               python3-ptyprocess-0.5.2-4.el8.noarch          
  python3-pysocks-1.6.8-3.el8.noarch                         python3-requests-2.20.0-3.el8_8.noarch    python3-setuptools-39.2.0-7.el8.noarch python3-systemd-234-8.el8.x86_64           python3-unbound-1.16.2-5.el8.x86_64            
  python3-urllib3-1.24.2-5.el8.noarch                        unbound-libs-1.16.2-5.el8.x86_64         
Complete!
[root@shawnyan yum.repos.d]# dnf update --allowerasing
Last metadata expiration check: 0:07:35 ago on Wed 25 Oct 2023 12:55:30 AM CST.
Dependencies resolved.
Nothing to do.
Complete!
[root@shawnyan yum.repos.d]#

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-3

升级后重启系统,并查看版本信息。

[root@shawnyan yum.repos.d]# cat /etc/redhat-release
Rocky Linux release 8.8 (Green Obsidian)
[root@shawnyan yum.repos.d]# uname -a
Linux shawnyan 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@shawnyan yum.repos.d]# reboot

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-4

Rocky 的登陆界面。

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-5

可以看到重启前后内核版本发生了变化。

Last login: Wed Oct 25 00:39:04 2023 from 192.168.8.1
[root@shawnyan ~]# cat /etc/redhat-release
Rocky Linux release 8.8 (Green Obsidian)
[root@shawnyan ~]# uname -a
Linux shawnyan 4.18.0-477.27.1.el8_8.x86_64 #1 SMP Wed Sep 20 15:55:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[root@shawnyan ~]# hostnamectl
   Static hostname: shawnyan
         Icon name: computer-vm
           Chassis: vm
        Machine ID: e7f51860c9c34455bcb755eac18c8868
           Boot ID: 788363ea2b7442c8a5f269aeb2ff2ab2
    Virtualization: vmware
  Operating System: Rocky Linux 8.8 (Green Obsidian)
       CPE OS Name: cpe:/o:rocky:rocky:8:GA
            Kernel: Linux 4.18.0-477.27.1.el8_8.x86_64
      Architecture: x86-64
[root@shawnyan ~]#

到此,操作系统版本已经从 CentOS 7.9 来到了 Rocky Linux 8.8,接下来,将升级到 Rocky 9。

从 Rocky 8 升级到 Rocky 9

与 CentOS 7 升级到 CentOS 8 类似,先切换 yum 源到 Rocky 9,然后执行 
dnf upgrade 升级命令。

[root@shawnyan yum.repos.d]# dnf upgrade --allowerasing
Last metadata expiration check: 0:00:28 ago on Wed 25 Oct 2023 01:14:48 AM CST.
Modular dependency problems:
Problem 1: conflicting requests
  - nothing provides module(platform:el8) needed by module container-tools:rhel8:8080020231004143727:8108cfbc.x86_64
Problem 2: conflicting requests
  - nothing provides module(platform:el8) needed by module go-toolset:rhel8:8080020230629185105:17f3f959.x86_64
Problem 3: conflicting requests
  - nothing provides module(platform:el8) needed by module idm:client:8080020230516222414:152c1be2.x86_64
Problem 4: conflicting requests
  - nothing provides module(platform:el8) needed by module llvm-toolset:rhel8:8080020230201094332:fd72936b.x86_64
Problem 5: conflicting requests
  - nothing provides module(platform:el8) needed by module swig:3.0:8040020210530171044:9f9e2e7e.x86_64
Problem 6: conflicting requests
  - nothing provides module(platform:el8) needed by module virt:rhel:8080020230922173645:fd72936b.x86_64
Dependencies resolved.
============================================================================================================================================================================================================================================
Package                                                                Architecture                           Version                                                              Repository                                         Size
============================================================================================================================================================================================================================================
Installing:
...
rocky-gpg-keys                                                         noarch                                 9.2-1.6.el9                                                          baseos                                             13 k
rocky-release                                                          noarch                                 9.2-1.6.el9                                                          baseos                                             23 k
rocky-repos                                                            noarch                                 9.2-1.6.el9                                                          baseos                                             12 k
...
Transaction Summary
============================================================================================================================================================================================================================================
Install   184 Packages
Upgrade  1057 Packages
Remove     22 Packages
Total download size: 844 M
Is this ok [y/N]: y
...
  Upgrading        : dracut-057-21.git20230214.el9.x86_64                                                                                                                                                                          803/2347
  Installing       : kernel-modules-core-5.14.0-284.30.1.el9_2.x86_64                                                                                                                                                              804/2347
  Installing       : kernel-core-5.14.0-284.30.1.el9_2.x86_64                                                                                                                                                                      805/2347
  Running scriptlet: kernel-core-5.14.0-284.30.1.el9_2.x86_64                                                                                                                                                                      805/2347
...
Complete!

安装完成,可以看到 kernel 版本已经来到了 5.14,重启系统并查看版本信息。

[root@shawnyan yum.repos.d]# cat /etc/redhat-release
Rocky Linux release 9.2 (Blue Onyx)
[root@shawnyan yum.repos.d]# uname -a
Linux shawnyan 4.18.0-477.27.1.el8_8.x86_64 #1 SMP Wed Sep 20 15:55:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[root@shawnyan yum.repos.d]# hostnamectl
Static hostname: shawnyan
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: e7f51860c9c34455bcb755eac18c8868
         Boot ID: 788363ea2b7442c8a5f269aeb2ff2ab2
  Virtualization: vmware
Operating System: Rocky Linux 9.2 (Blue Onyx)       
     CPE OS Name: cpe:/o:rocky:rocky:9::baseos
          Kernel: Linux 4.18.0-477.27.1.el8_8.x86_64
    Architecture: x86-64
Firmware Version: 6.00
[root@shawnyan yum.repos.d]# reboot

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-7

进入系统,查看版本。

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-8

到此,从 Rocky 8 升级到 Rocky 9 的所有步骤已经完成。

结语

本文从提笔到完成,零零总总过去了一个月时间,从 CentOS 7 升级到 Rocky 9 这种跨大版本,跨发行版本的升级是非常复杂的。

而且,升级操作系统本身,就是一个系统工程,影响范围非常之广,对于 DBA 而言,还需要进行数据库对新系统的一些兼容性测试。

简言之,升级操作系统版本,过程非常复杂,耗时非常之久。故而并不建议如此操作,而是建议直接采购新机器,在新机器上安装新系统,后期再做数据迁移。

下一期,我们来聊聊如何从头 
一步一步安装 Rocky Linux 9 
 。

【Rocky 9】Step by Step 从 CentOS 7.9 升级到 Rocky Linux 9.2-9

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论