在将CentOS8.2升级到AlmaLinux的过程中遇到的问题

背景 – 环境或上下文中的信息和条件。

由于CentOS 8版本到达了生命周期结束点,所以我们需要迁移到受支持的操作系统。
我们决定将迁移目标设置为具有与CentOS兼容性且提供较长保证期的almalinux,因此进行了迁移工作。

总结

如果/etc/yum.repos.d目录中存在CentOS-Stream*文件,执行yum update命令可能会将操作系统更新为CentOS Stream 8版本。如果这会导致问题,您可以通过排除上述文件来将操作系统更新为CentOS 8系列的最新版(在写作时为8.5)。

环境

CentOS 8.2 简体中文:CentOS 8.2

预定的过渡步骤

CentOS 8.2 → CentOS 8.5 的更新需要通过 dnf update 命令完成,而从 CentOS 8.5 迁移到 almalinux 则需要使用移行脚本。

执行

首先,进行系统备份。

# OSバージョン確認確認
[root@test-server ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)

# dnf updateができるか確認
[root@test-server ~]# dnf update
CentOS-8 - AppStream                                                                                                                                           115  B/s |  38  B     00:00
エラー: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

# yum でエラーが発生
# CentOS8は、サポート終了しているため。yum リポジトリのURL書き換えが必要。

# /etc/yum.repos.d/内容を確認
[root@test-server yum.repos.d]# ls -la /etc/yum.repos.d/CentOS-*
-rw-r--r--  1 root root  732  4月 19 14:10 /etc/yum.repos.d/CentOS-AppStream.repo
-rw-r--r--  1 root root  713  4月 19 14:10 /etc/yum.repos.d/CentOS-Base.repo
-rw-r--r--. 1 root root 1043  9月 16  2020 /etc/yum.repos.d/CentOS-CR.repo
-rw-r--r--. 1 root root  668  9月 16  2020 /etc/yum.repos.d/CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  743  9月 16  2020 /etc/yum.repos.d/CentOS-Devel.repo
-rw-r--r--  1 root root  757  4月 19 14:10 /etc/yum.repos.d/CentOS-Extras.repo
-rw-r--r--. 1 root root  738  9月 16  2020 /etc/yum.repos.d/CentOS-HA.repo
-rw-r--r--. 1 root root  928  9月 16  2020 /etc/yum.repos.d/CentOS-Media.repo
-rw-r--r--  1 root root  735  4月 19 14:11 /etc/yum.repos.d/CentOS-PowerTools.repo
-rw-r--r--. 1 root root 1382  9月 16  2020 /etc/yum.repos.d/CentOS-Sources.repo
-rw-r--r--  1 root root  725 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-AppStream.repo
-rw-r--r--  1 root root  706 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-Base.repo
-rw-r--r--  1 root root  666 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-Debuginfo.repo
-rw-r--r--  1 root root  750 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-Extras.repo
-rw-r--r--  1 root root  932 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-Media.repo
-rw-r--r--  1 root root  730 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-PowerTools.repo
-rw-r--r--  1 root root 1374 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-Sources.repo
-rw-r--r--  1 root root   74 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-Vault.repo
-rw-r--r--  1 root root  796 12月 20  2019 /etc/yum.repos.d/CentOS-Stream-centosplus.repo
-rw-r--r--. 1 root root   74  9月 16  2020 /etc/yum.repos.d/CentOS-Vault.repo
-rw-r--r--. 1 root root  798  9月 16  2020 /etc/yum.repos.d/CentOS-centosplus.repo
-rw-r--r--. 1 root root  338  9月 16  2020 /etc/yum.repos.d/CentOS-fasttrack.repo

# sedによる書き換えを実施。
# 他のリポジトリでもエラーが出る場合は、書き換える対象ファイルを追加してください。
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-AppStream.repo
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Extras.repo
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-AppStream.repo
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Extras.repo

# dnf update確認
[root@test-server ~]# dnf update
CentOS-8 - PowerTools                                                                                                                                           15 MB/s | 2.3 MB     00:00
CentOS-Stream - AppStream                                                                                                                                       16 kB/s | 4.4 kB     00:00
CentOS-Stream - AppStream                                                                                                                                       32 MB/s |  21 MB     00:00
CentOS-Stream - Base                                                                                                                                           7.3 kB/s | 3.9 kB     00:00
CentOS-Stream - Base                                                                                                                                           3.0 MB/s |  21 MB     00:06
CentOS-Stream - Extras                                                                                                                                         8.5 kB/s | 2.9 kB     00:00
CentOS-Stream - Extras                                                                                                                                          31 kB/s |  18 kB     00:00
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                                                          16 kB/s | 8.7 kB     00:00
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                                                         1.0 MB/s | 1.0 MB     00:01
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                                  18 kB/s | 9.8 kB     00:00
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                                 1.9 MB/s |  11 MB     00:05
依存関係が解決しました。
===============================================================================================================================================================================================
 パッケージ                                             アーキテクチャー            バージョン                                                     リポジトリー                          サイズ
===============================================================================================================================================================================================
インストール中:
 centos-stream-release                                  noarch                      8.6-1.el8                                                      Stream-BaseOS                          22 k
     置き換え  centos-release.x86_64 8.2-2.2004.0.2.el8
     置き換え  centos-release-stream.x86_64 8.1-1.1911.0.7.el8
     置き換え  centos-repos.x86_64 8.2-2.2004.0.2.el8
 kernel                                                 x86_64                      4.18.0-373.el8                                                 Stream-BaseOS                         8.0 M
 kernel-core                                            x86_64                      4.18.0-373.el8                                                 Stream-BaseOS                          39 M
 kernel-modules                                         x86_64                      4.18.0-373.el8                                                 Stream-BaseOS                          32 M
アップグレード中:
 NetworkManager                                         x86_64                      1:1.39.0-1.el8                                                 Stream-BaseOS                         2.3 M
 NetworkManager-libnm                                   x86_64                      1:1.39.0-1.el8                                                 Stream-BaseOS

(中略)

需要注意的是,代码库中的 Stream-BaseOS 部分。
如果继续执行 dnf update 的话,将会更新到 CentOS Stream 8。

我在当前状态下尝试运行从CentOS Stream 8迁移到almalinux的迁移脚本,但是在进行操作系统版本检查时出现了错误,无法执行。

[root@test-server almalinux-deploy]# bash almalinux-deploy.sh
Check root privileges                                                 OK
Detect centos version                                                 ERROR
Check EL is supported                                                 ERROR

应对

首先,将操作系统回滚到作业前的状态。

#CentOS-Stream 系ののリポジトリファイル除外
[root@test-server ~]#mv -i /etc/yum.repos.d/CentOS-Stream* /tmp/

# dnf updateの確認
# リポジトリ欄が BaseOSに変更されているところに注目。
[root@test-server yum.repos.d]dnf update
メタデータの期限切れの最終確認: 0:03:04 時間前の 2022年04月19日 14時11分49秒 に実施しました。
依存関係が解決しました。
===============================================================================================================================================================================================
 パッケージ                                            アーキテクチャー               バージョン                                                       リポジトリー                      サイズ
===============================================================================================================================================================================================
インストール中:
 centos-linux-release                                  noarch                         8.5-1.2111.el8                                                   BaseOS                             22 k
     置き換え  centos-release.x86_64 8.2-2.2004.0.2.el8
     置き換え  centos-repos.x86_64 8.2-2.2004.0.2.el8
 kernel                                                x86_64                         4.18.0-348.7.1.el8_5                                             BaseOS                            7.0 M
 kernel-core                                           x86_64                         4.18.0-348.7.1.el8_5                                             BaseOS                             38 M
 kernel-modules                                        x86_64                         4.18.0-348.7.1.el8_5                                             BaseOS                             30 M
アップグレード中:
 NetworkManager                                        x86_64                         1:1.32.10-4.el8                                                  BaseOS                            2.6 M
 NetworkManager-libnm                                  x86_64                         1:1.32.10-4.el8                                                  BaseOS                            1.8 M

(中略)

# dnf updateを実行

# OS再起動してバージョンの確認
[root@test-server ~]# shutdouwn -r now
[root@test-server ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111

# /etc/yum.repos.d/の中身。CentOS-Linux-*のリポジトリがファイルが作成される。
[root@test-server yum.repos.d]# ls -la /etc/yum.repos.d/CentOS-*
-rw-r--r-- 1 root root  732  4月 19 14:10 CentOS-AppStream.repo.rpmsave
-rw-r--r-- 1 root root  713  4月 19 14:10 CentOS-Base.repo.rpmsave
-rw-r--r-- 1 root root  757  4月 19 14:10 CentOS-Extras.repo.rpmsave
-rw-r--r-- 1 root root  719  9月 15  2021 CentOS-Linux-AppStream.repo
-rw-r--r-- 1 root root  704  9月 15  2021 CentOS-Linux-BaseOS.repo
-rw-r--r-- 1 root root 1130  9月 15  2021 CentOS-Linux-ContinuousRelease.repo
-rw-r--r-- 1 root root  318  9月 15  2021 CentOS-Linux-Debuginfo.repo
-rw-r--r-- 1 root root  732  9月 15  2021 CentOS-Linux-Devel.repo
-rw-r--r-- 1 root root  704  9月 15  2021 CentOS-Linux-Extras.repo
-rw-r--r-- 1 root root  719  9月 15  2021 CentOS-Linux-FastTrack.repo
-rw-r--r-- 1 root root  740  9月 15  2021 CentOS-Linux-HighAvailability.repo
-rw-r--r-- 1 root root  693  9月 15  2021 CentOS-Linux-Media.repo
-rw-r--r-- 1 root root  706  9月 15  2021 CentOS-Linux-Plus.repo
-rw-r--r-- 1 root root  724  9月 15  2021 CentOS-Linux-PowerTools.repo
-rw-r--r-- 1 root root 1124  9月 15  2021 CentOS-Linux-Sources.repo
-rw-r--r-- 1 root root  735  4月 19 14:11 CentOS-PowerTools.repo.rpmsave

# まだCentOS 8系なので、以前、ミラーリストの差し替えが必要
[root@test-server yum.repos.d]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
[root@test-server yum.repos.d]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*

# migrationツール取得と実行
[root@test-server ~]# git clone https://github.com/AlmaLinux/almalinux-deploy.git
[root@test-server ~]# cd almalinux-deploy
[root@test-server ~]# bash almalinux-deploy.sh
(中略)

完了しました!
Run dnf distro-sync -y                                                OK
Restoring of alternatives is done                                     OK
Generating grub configuration file ...
File descriptor 5 (/var/log/almalinux-deploy.debug.log) leaked on vgs invocation. Parent PID 68385: /usr/sbin/grub2-probe
File descriptor 5 (/var/log/almalinux-deploy.debug.log) leaked on vgs invocation. Parent PID 68385: /usr/sbin/grub2-probe
File descriptor 5 (/var/log/almalinux-deploy.debug.log) leaked on vgs invocation. Parent PID 70483: /usr/sbin/grub2-probe
File descriptor 5 (/var/log/almalinux-deploy.debug.log) leaked on vgs invocation. Parent PID 70483: /usr/sbin/grub2-probe
done
All Secure Boot related packages which were not released by AlmaLinux are reinstalledOK

Migration to AlmaLinux is completed

# OS再起動とバージョン確認
[root@test-server ~]# shutdouwn -r now
[root@test-server ~]# cat /etc/redhat-release
AlmaLinux release 8.5 (Arctic Sphynx)

以上です, 操作系统升级已经完成。辛苦了。

印象

系统备份真是太好了。

The external information

AlmaLinux的迁移
https://github.com/AlmaLinux/almalinux-deploy

广告
将在 10 秒后关闭
bannerAds