CentOS8.3にMariaDB10.5をインストール


結構手こずってしまったのでメモします。

環境

CentOS Linux release 8.3.2011

  • イメージファイルは「CentOS-8-x86_64-1905-dvd1.iso」
  • 「最小限のインストール」でインストール
  • 実行したdnfコマンドはdnf -y updatednf -y install chronyのみ

何をしたかったか

CentOS8にMariaDB Community Serverの最新版(10.5.8)をインストールしたかった

参考にした手順

実際の手順

mariadb_repo_setup によるレポジトリ設定

成功

os-typeとos-versionを指定しました。
https://mariadb.com/kb/en/mariadb-package-repository-setup-and-usage/#using-the-mariadb-package-repository-setup-script

# curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --os-type=rhel --os-version=8

失敗

os-typeとos-versionを指定しないと失敗しました。

# curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
[error] Detected RHEL or compatible but version () is not supported.
[error] The MariaDB Repository supports these Linux OSs, on x86-64 only:
    * RHEL/CentOS 6, 7, & 8
    * Ubuntu 16.04 LTS (xenial), 18.04 LTS (bionic), & 20.04 LTS (focal)
    * Debian 9 (stretch), & 10 (buster)
    * SLES 12 & 15
[error] See https://mariadb.com/kb/en/mariadb/mariadb-package-repository-setup-and-usage/#platform-support

CentOS8.3から、CentOSのrpmパッケージ名が変わり、
mariadb_repo_setupの処理でOSバージョンが取れなくなったことが原因のようです。
(以前は「centos-release-8.2-2.2004.0.2.el8.x86_64」など)

# rpm -qa | grep centos
centos-linux-release-8.3-1.2011.el8.noarch
centos-gpg-keys-8-2.el8.noarch
centos-linux-repos-8-2.el8.noarch

必要なパッケージのインストール

成功

1. MaxScaleレポジトリを無効(enabled = 1 を enabled = 0)にする

/etc/yum.repos.d/mariadb.repo
[mariadb-main]
name = MariaDB Server
baseurl = https://downloads.mariadb.com/MariaDB/mariadb-10.5/yum/rhel/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEY
gpgcheck = 1
enabled = 1
module_hotfixes = 1

[mariadb-maxscale]
# To use the latest stable release of MaxScale, use "latest" as the version
# To use the latest beta (or stable if no current beta) release of MaxScale, use "beta" as the version
name = MariaDB MaxScale
baseurl = https://dlm.mariadb.com/repo/maxscale/latest/centos/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-MaxScale-GPG-KEY
gpgcheck = 1
enabled = 0

[mariadb-tools]
name = MariaDB Tools
baseurl = https://downloads.mariadb.com/Tools/rhel/$releasever/$basearch
gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Enterprise-GPG-KEY
gpgcheck = 1
enabled = 1

2. 必要なパッケージをインストールする

# dnf -y install perl-DBI libaio libsepol lsof boost-program-options rsync

失敗

MaxScaleレポジトリでSSL証明書の認証エラーが発生し、メタデータが入手できませんでした。
私はMaxScaleレポジトリを使わないので、無効化しました。
(メッセージは長かったので省略しています)

# dnf -y install perl-DBI libaio libsepol lsof boost-program-options rsync
MariaDB MaxScale                                0.0  B/s |   0  B     00:04
Errors during downloading metadata for repository 'mariadb-maxscale':
  - Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://storage.googleapis.com/downloads-cdn.mariadb.com/mariadbmaxscale/2.5/2.5.5/centos/8/x86_64/repodata/repomd.xml?GoogleAccessId=downloads-sync%40downloads-234321.iam.gserviceaccount.com&Expires=1607483040&Signature=EW6MGYvRwjxY%2BT7NHw6MZZygmHIwW2tJ1DxEf4tE99t9I6J0kGBdTRn5xYs0lyICGESaCwTbBCRvuU%2Bw6oXwFSsSj7N9U%2Bv0Uzlh2Q0Eeml3TIFM%2B6NZPJ1ny96cr7UqCYgO7S5Vj6jT4PxrRyJ%2BVl5i77qraEtR9OB3uxlPaEqfib7ODF%2FyfEHsRW7rcVsZ6ZzcKmDUN8VJUYDxMPulkUEUkBp%2FSuVM5bmUikvXlaR0sp%2FhnYt8sIZua%2B5xQUwZu9UXpIRF90eqz5wR%2B5HSXakjx0zYQd0wlwx8u4g1Tviw%2Fi%2F8ZQyHRaL1QfaD50DlDFYaTwZTs1fCwGqom4hAZw%3D%3D [SSL certificate problem: self signed certificate in certificate chain]

~ 中略 ~

エラー: repo 'mariadb-maxscale' のメタデータのダウンロードに失敗しました : Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

MariaDB Community Serverのインストール

成功

1. tarをインストールする

dnf -y install tar

2. MariaDB Community Serverをインストールする

# dnf -y install --repo=mariadb-main MariaDB-server

失敗

tarが無いために失敗していたという悲しいオチでした。
色々な方が「CentOS8にはtarが入ってないぞ」と書いてくださっている中で…。

# dnf -y install --repo=mariadb-main MariaDB-server
メタデータの期限切れの最終確認: 0:00:26 時間前の 2020年12月09日 13時41分41秒 に 実施しました。
エラー:
 問題: cannot install the best candidate for the job
  - nothing provides tar needed by MariaDB-server-10.5.8-1.el8.x86_64
(インストール不可のパッケージをスキップするには、'--skip-broken' を追加してみて ください または、'--nobest' を追加して、最適候補のパッケージのみを使用しないでください)

nothing provides tar needed by MariaDB-server-10.5.8-1.el8.x86_64
「何のことか分からないが、tarファイルが見つからない?」と解釈して右往左往し、
「まさか…tarコマンドのことじゃないよね…?」と思い立ち、試したらうまくいきました。

さいごに

今回初めてCentOS8を触ったのですが、扱い慣れていたCentOS7との違いに四苦八苦してしまいました。

新しいものをどんどん触らないとダメ、、と反省しました。

一時間以上悩んでしまったので、この記事が誰かのお役に立てたら嬉しいです。
最後までご覧いただきありがとうございました。