LoginSignup
3
1

More than 1 year has passed since last update.

CentOS8.xからCentOS Stream 8へ移行した

Last updated at Posted at 2022-06-14
../

VPSサーバーをCentOS8.xからCentOS Stream 8に移行してみた。基本的な手順は、以下のようになる。

$ dnf install centos-release-stream
$ dnf swap centos-linux-repos 
$ dnf swap centos-stream-repos
$ dnf distro-sync

移行前のCentOSのバージョンは、8.5に上がっていた。

$ cat /etc/redhat-release 
CentOS Linux release 8.5.2111

$ dnf install centos-release-stream
$ dnf swap centos-linux-repos
$ dnf swap centos-stream-repos
$ dnf distro-sync

dnf distro-syncでエラーが大量に出た。「パッケージの最良アップデート候補をインストールできません」のエラーが出たら、指示に従い、競合するパッケージを置き換えるためにコマンドラインにオプションを追加して再実行する。

$ dnf distro-sync --allowerasing --skip-broken --nobest

900個くらいのアップグレードが行われた。

$ cat /etc/centos-release
CentOS Stream release 8

$ dnf update

CentOS Stream 8に移行できた。しかし、updateや、オプションなしでdistro-syncするとエラーがかなりある。

epel.repoなどへの対応

CentOS8がEOLで終了したため、古いレポジトリではyumやdnfでダウンロードできなくなったものもある。epelは、Fedoraプロジェクトが運用しているリポジトリである。versionが「7」の箇所は「$releasever」または「8」に変えておく。また「Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/epel.repo;」のようなワーニングが出たら、failovermethod=priority の行を削除またはコメントアウトしておく。

$ vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

[epel-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1

「パッケージ epel-release-7-14.noarch は既にインストールされています。epel-release-8-15.el8.noarch はインストールできません」のエラーが出たので、一旦epel-releaseをremoveして、installし直した。

$ dnf remove epel-release
$ dnf install epel-release

repolistの結果は、以下の感じになった。clean allして、updateした。

$ dnf repolist
repo id             repo の名前
appstream           CentOS Stream 8 - AppStream
baseos              CentOS Stream 8 - BaseOS
elrepo              ELRepo.org Community Enterprise Linux Repository - el8
epel                Extra Packages for Enterprise Linux 8 - x86_64
epel-modular        Extra Packages for Enterprise Linux Modular 8 - x86_64
extras              CentOS Stream 8 - Extras
extras-common       CentOS Stream 8 - Extras common packages

$ dnf clean all
93 ファイルが削除されました。

$ dnf update
CentOS Stream 8 - AppStream                     4.8 MB/s |  23 MB     00:04    
CentOS Stream 8 - BaseOS                        4.9 MB/s |  23 MB     00:04    
CentOS Stream 8 - Extras                         31 kB/s |  18 kB     00:00    
CentOS Stream 8 - Extras common packages         12 kB/s | 4.3 kB     00:00    
ELRepo.org Community Enterprise Linux Repositor 113 kB/s | 230 kB     00:02    
Extra Packages for Enterprise Linux 8 - x86_64  5.0 MB/s |  11 MB     00:02    
Extra Packages for Enterprise Linux Modular 8 - 4.1 MB/s | 1.0 MB     00:00    
Extra Packages for Enterprise Linux 8 - Next -  631 kB/s | 559 kB     00:00   

エラーが出なくなるまで、以下を数回繰り返した。

$ dnf distro-sync
$ dnf update

MySQL8.0の再設定

実は、MySQL8.0も競合してうまく行かなかったので、関連するrepoを一旦削除し、remove とinstallを行った。以前CentOS8.xのときに独自にrpmを取り込んでいたが、CentOS Stream 8 - AppStreamには標準でMySQL8.0が含まれるようになったためだろう。

$ dnf repolist
・・・
mysql-connectors-community    MySQL Connectors Community
mysql-tools-community         MySQL Tools Community

$ cd /etc/yum.repos.d/
$ rm -f mysql-*

$ dnf remove mysql
$ dnf module list mysql
CentOS Stream 8 - AppStream
Name          Stream             Profiles                   Summary             
mysql         8.0 [d][e]         client, server [d]         MySQL Module  

$ dnf moduleinstall mysql:8.0
mysql-server   x86_64  8.0.26-1.module_el8.4.0+915+de215114   appstream   25 M
mecab          x86_64  0.996-1.module_el8.4.0+589+11e12751.9  appstream  393 k
mysql          x86_64  8.0.26-1.module_el8.4.0+915+de215114   appstream   12 M
mysql-errmsg   x86_64  8.0.26-1.module_el8.4.0+915+de215114   appstream  598 k
protobuf-lite  x86_64  3.5.0-15.el8                           appstream  149 k
 
$ mysql --version
mysql  Ver 8.0.26 for Linux on x86_64 (Source distribution)

/etc/my.cnf.d/にある設定ファイルを修正し、サービスを再実行する。DB内のデータは残っているのでサービス実行のための設定のみできれば、復活する。

$ vi /etc/my.cnf.d/mysql-server.cnf
[mysqld]
character-set-server=utf8
lower_case_table_names=1  # 大文字小文字を区別しない場合

$ vi /etc/my.cnf.d/client.cnf
[client]
default-character-set=utf8

$ systemctl restart mysqld
$ systemctl status mysqld
$ mysql -uroot -p 
・・・
../
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1