自宅サーバーのCentOS7をAlmaLinux8にアップグレードする

yasuです。

今回は自宅サーバーのCentOS7をAlmaLinux8にアップグレードしましたってお話です。
元々5年くらい前にFujitsuのPRIMERGY TX100 S3という格安サーバー機にCentOS7をインストールして、Webサーバー、DBサーバー、ブログサーバー、チャットサーバー、DNSサーバー、メールサーバー、プロキシサーバー、DHCPサーバー・・・などなど色々なサーバーを立てて、このブログサーバーを始め各種サーバーを立てて遊んでいました。
その後、ちょっと古めの中古ハイエンドマザーのASUS X99A-Ⅱとヤフオクで安く購入したXeon E5-2698 V3に、AlmaLinux8とKVMをインストールして仮想サーバーを構築して、TX100 S3のディスクイメージを吸い出し、仮想サーバーに移して運用するようになりました。
さらにDNSサーバー、チャットサーバー、プロ指揮サーバーなど一部サーバーアプリは別の仮想サーバーに移行して、CentOS7で動いているサービスは、ブログサーバー(Webサーバー+DBサーバー)とオンラインストレージサーバー、メールサーバーくらいとなり、今日まで運用を続けていたのですが、CentOS7のサポート期間が今月末で切れてしまうということもあり、サーバーのリソースも余っていたので、新しい仮想サーバーにAlmaLinux9を準備して、そこに1から環境を作ろうと思っていたのですが、なかなか重い腰があがらず、取り急ぎという感じでアップグレードを実施しました。

今までサーバーOSのアップグレードなんてやってことがないので、ネットでCentOS7からAlmaLinux8や9に移行されている方がいらっしゃるのか調べてみたら、そこそこやっていらっしゃる方がいて、さらにELevate projectなるプロジェクトで作成されているツールを使うと比較的簡単にアップグレードできるということで早速試してみました。
ちなみにOSのアップグレードは比較的簡単に終わったのですが、やっぱり中で動いているサーバーアプリがかなりあちこち動かなくなり、最後に色々はまりました事はお伝えしておきます。

では早速手順をご紹介です。

システムをアップデートして最新のアップデートを入手し、サーバーを再起動する

# yum update -y
# reboot

プロジェクトリポジトリとGPGキーを使用して、elevate-releaseパッケージをインストールする

# yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm

AlmaLinuxのleappパッケージと移行データをインストールする

# yum install -y leapp-upgrade leapp-data-almalinux

プレアップデートを実施

# leapp preupgrade
==> Processing phase `configuration_phase`
====> * ipu_workflow_config
        IPU workflow config actor
==> Processing phase `FactsCollection`
====> * vendor_repositories_mapping
        Scan the vendor repository mapping files and provide the data to other actors.
   ・
   ・
   ・
Total size: 1.0 G
Total download size: 906 M
Downloading Packages:
Check completed.
====> * report_set_target_release
        Reports information related to the release set in the subscription-manager after the upgrade.
====> * local_repos_inhibit
        Inhibits the upgrade if local repositories were found.
====> * tmp_actor_to_satisfy_sanity_checks
        The actor does NOTHING but satisfy static sanity checks
====> * check_initramfs_tasks
        Inhibit the upgrade if conflicting "initramfs" tasks are detected
==> Processing phase `Reports`
====> * verify_check_results
        Check all dialogs and notify that user needs to make some choices.
====> * verify_check_results
        Check all generated results messages and notify user about them.

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

Upgrade has been inhibited due to the following problems:
    1. 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

最後にアップグレードは禁止と出てきてしまいました。
ログファイル /var/log/leapp/answerfile を見ろということで、ログファイルを見てみます。

#vi /var/log/leapp/answerfile
-----------------------------------------------------------------------------
[remove_pam_pkcs11_module_check]
# Title:              None
# Reason:             Confirmation
# =================== remove_pam_pkcs11_module_check.confirm ==================
# Label:              Disable pam_pkcs11 module in PAM configuration? If no, the upgrade process will be interrupted.
# Description:        PAM module pam_pkcs11 is no longer available in RHEL-8 since it was replaced by SSSD.
# Reason:             Leaving this module in PAM configuration may lock out the system.
# Type:               bool
# Default:            None
# Available choices: True/False
# Unanswered question. Uncomment the following line with your answer
# confirm =
-----------------------------------------------------------------------------

因は「応答ファイルに必要な回答がない」ということなので、参考サイトを元に以下のオペレーションを実施します。

# leapp answer --section remove_pam_pkcs11_module_check.confirm=True

応答ファイルを確認します。

# view /var/log/leapp/answerfile
-----------------------------------------------------------------------------
 [remove_pam_pkcs11_module_check]
confirm = True
-----------------------------------------------------------------------------

プレアップグレード直後はconfirm =がコメント化されていましたが、今度はconfirm = Trueとなりました。
どうやらこれでOKなようです。
再度プレアップグレードを実施します。

# leapp preupgrade

Total size: 1.0 G
Total download size: 906 M
Downloading Packages:
Check completed.
====> * local_repos_inhibit
        Inhibits the upgrade if local repositories were found.
====> * report_set_target_release
        Reports information related to the release set in the subscription-manager after the upgrade.
====> * tmp_actor_to_satisfy_sanity_checks
        The actor does NOTHING but satisfy static sanity checks
====> * check_initramfs_tasks
        Inhibit the upgrade if conflicting "initramfs" tasks are detected
==> Processing phase `Reports`
====> * verify_check_results
        Check all dialogs and notify that user needs to make some choices.
====> * verify_check_results
        Check all generated results messages and notify user about them.

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

今度はアップグレード禁止にならず終了しました。

アップグレード実施

# leapp upgrade
・
・
・
Total size: 1.1 G
DNF will only download packages, install gpg keys, and check the transaction.
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Complete!
====> * add_upgrade_boot_entry
        Add new boot entry for Leapp provided initramfs.
A reboot is required to continue. Please reboot your system.


Debug output written to /var/log/leapp/leapp-upgrade.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

アップグレード処理も無事完了したので、OSを再起動します。

# reboot

サーバを再起動すると、実際のアップグレードが始まりますのでしばし待ちます。
ちなみに我が家の仮想サーバーではアップグレード完了まで1時間半くらいかかりました。

OSバージョン確認

アップグレードが終わったので、sshでログインしてバージョンを確認します。

# cat /etc/redhat-release
AlmaLinux release 8.10 (Cerulean Leopard)

はい、AlmaLinux 8.10になっていますね。
ここまでは大きな問題もなくすんなりアップグレードできました。
が、ここからが大変でメールが閲覧できない、WordPressやNextCloudの管理画面が出てきませんでした。
ということで、掻い摘まんで実施した事をメモしておきます。

DovecotのSSL設定ファイル対応

AlmaLinux8アップグレード後に確認したDovecotのバージョンは2.3.16でした。
SSLの設定ファイルに追加設定が必要ということで、設定を行います。

# openssl dhparam -out /etc/dovecot/dh.pem 4096

# vi /etc/dovecot/conf.d/10-ssl.conf
※以下を追記
ssl_dh = </etc/dovecot/dh.pem
ssl_min_protocol = TLSv1.2

# systemctl restart dovecot

PHPインストール

CentOS7の時にPHP8.1をインストールしてあったはずなのですが、バージョンを確認してみたところ7.2.24になっていたので、改めてPHP8.1をインストールします。

※ remiリポジトリをインストール
# dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

※ PHPのデフォルトバージョンをremiリポジトリの8.1に変更
# dnf module reset php
# dnf module enable php:remi-8.1

※ PHP8.1をインストール
# dnf install php-mysql
'dnf clean packages' を実行することでキャッシュパッケージを削除できます。
エラー: トランザクションテストエラー:
  ファイル /usr/lib64/libzip.so.5.5 (パッケージ libzip-1.10.1-1.el8.remi.x86_64 から) は、パッケージ libzip5-1.10.1-1.el7.remi.x86_64 からのファイルと競合しています。

※libzip競合エラーの解消
# dnf remove libzip

※ PHP8.1のインストール再実行
# dnf install php-mysql

これでWordPressの管理画面にアクセスできるようになったのですが、NextCloudの管理画面は以前としてエラーになります。
そういえばCentOS7でNextCloudを運用していた時に、MemCacheやRedisをインストールして設定したのを思い出したので、必要なアプリケーションをインストールしていきます。

Redisインストール

# dnf module list redis
# dnf module reset redis
# dnf module enable redis:6
# dnf install redis
# systemctl start redis
Job for redis.service failed because the control process exited with error code.
See "systemctl status redis.service" and "journalctl -xe" for details.

はい、Redisが起動しません。
原因がよくわからないので、アンインストールと設定ファイル削除、rdbファイルの削除を行い、再インストールしたところ、サービスが起動するようになりました。

# dnf remove redis
# rm -fr /etc/redis*
# cd /var/lib/redis
# rm dump.rdb
# systemctl start redis
# systemctl enable redis

他、NextCloudに必要なパッケージを追加していきます。

その他NextCloudに必要なパッケージのインストール

# dnf install php-pear php-mbstring php-pdo php-intl php-gd php-pecl-zip php-mysqlnd php-bcmath php-gmp php-opcache php-pecl-apcu php-devel php-pecl-imagick php-redis memcached php-pecl-memcache

ここまで実施してようやくNextCloudの管理画面にアクセスできるようになりました。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です