MariaDBを10.3にアップグレードする際の手順と注意事項

MariaDBを10.3にアップグレードする際の手順と注意事項 サーバー

MariaDBを10.3未満から10.3にアップグレードする際の注意事項と手順です。

公式サイトに記載された手順をもとに古いMariaDBを一旦全て削除してから最新版のインストールを行った方法と、MariaDB-serverだけrpmで削除して他は上書きでインストールした方法の2種類を解説します。

※動作確認環境
CentOS 7.6
MariaDB 10.1から10.3に変更

■新規でMariaDB 10.3をインストールする際は以下のページをご覧ください。

現在のMariaDBの確認

まず、今現在利用中のインストール済みのMariaDBを調べます。

# yum list installed | grep mariadb
MariaDB-client.x86_64                   10.1.37-1.el7.centos           @mariadb 
MariaDB-common.x86_64                   10.1.37-1.el7.centos           @mariadb 
MariaDB-devel.x86_64                    10.1.37-1.el7.centos           @mariadb 
MariaDB-server.x86_64                   10.1.37-1.el7.centos           @mariadb 
MariaDB-shared.x86_64                   10.1.37-1.el7.centos           @mariadb 
galera.x86_64                           25.3.24-1.rhel7.el7.centos     @mariadb
# mysql -V
mysql  Ver 15.1 Distrib 10.1.37-MariaDB, for Linux (x86_64) using readline 5.1

このMariaDB 10.1を10.3にアップグレードしていきます。

リポジトリの更新

既存のリポジトリの確認

「yum repolist」で現在登録されているリポジトリを確認します。

# yum repolist
読み込んだプラグイン:fastestmirror, langpacks
Determining fastest mirrors
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * epel-debuginfo: ftp.iij.ad.jp
 * epel-source: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
リポジトリー ID                           リポジトリー名                                                          状態
base/7/x86_64                             CentOS-7 - Base                                                         10,019
epel/x86_64                               Extra Packages for Enterprise Linux 7 - x86_64                          12,860
epel-debuginfo/x86_64                     Extra Packages for Enterprise Linux 7 - x86_64 - Debug                   2,865
epel-source/x86_64                        Extra Packages for Enterprise Linux 7 - x86_64 - Source                      0
extras/7/x86_64                           CentOS-7 - Extras                                                          321
mariadb                                   MariaDB                                                                     76
updates/7/x86_64                          CentOS-7 - Updates                                                         643
repolist: 26,775

このMariaDBのリポジトリを更新します。

curlでリポジトリの更新を行う場合

curlでリポジトリの最新版をインストールする場合は、古い同じ名前のリポジトリは「mariadb.repo.old_1」という風に「/etc/yum.repos.d/」内にバックアップしてくれますので便利です。

# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash
[warning] Found existing file at /etc/yum.repos.d/mariadb.repo. Moving to /etc/yum.repos.d/mariadb.repo.old_1.
[info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo.
[info] Adding trusted package signing keys...
[info] Succeessfully added trusted package signing keys.

手動でリポジトリ(.repoファイル)を書き換える場合

CentOS 7の場合は「/etc/yum.repos.d/mariadb.repo」をvi等で書き換えてください。

※MariaDB 10.3用のリポジトリ設定はMariaDB公式サイトにて確認できます。

# vi /etc/yum.repos.d/mariadb.repo

リポジトリ情報をリロード

書き換えたらリポジトリ情報をリロードします。

# yum clean all

【選択肢1】yumで既存のMariaDBを全削除してから10.3をインストール

※この方法は、公式サイトに記載された手順を参考に行う手順ですが、MariaDBをyumで削除すると他の依存パッケージも削除されてしまいます。

環境によっては多数のパッケージが削除される可能性があり、その復旧作業で結構な手間が掛かりますので、手間が掛かっても全部削除してスッキリしてから新しくインストールしたいという方以外は次の見出しにある「【選択肢2】rpmでMariaDB-serverだけ削除してから10.3をyumでインストール」をお勧めします。

依存関係の調査

まず、yum removeの実行テストをして既存のMariaDBの依存関係を調べます。

※依存関係のテストなので途中で必ず[N]で削除を停止してください。
# yum remove MariaDB-*
読み込んだプラグイン:fastestmirror, langpacks
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-client.x86_64 0:10.1.37-1.el7.centos を 削除
---> パッケージ MariaDB-common.x86_64 0:10.1.37-1.el7.centos を 削除
---> パッケージ MariaDB-devel.x86_64 0:10.1.37-1.el7.centos を 削除
---> パッケージ MariaDB-server.x86_64 0:10.1.37-1.el7.centos を 削除
---> パッケージ MariaDB-shared.x86_64 0:10.1.37-1.el7.centos を 削除
--> 依存性の処理をしています: libmysqlclient.so.18()(64bit) のパッケージ: 2:postfix-2.10.1-7.el7.x86_64
--> 依存性の処理をしています: libmysqlclient.so.18(libmysqlclient_18)(64bit) のパッケージ: 2:postfix-2.10.1-7.el7.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ postfix.x86_64 2:2.10.1-7.el7 を 削除
--> 依存性解決を終了しました。

依存性を解決しました

========================================================================================================================
 Package                       アーキテクチャー      バージョン                          リポジトリー              容量
========================================================================================================================
削除中:
 MariaDB-client                x86_64                10.1.37-1.el7.centos                @mariadb                 172 M
 MariaDB-common                x86_64                10.1.37-1.el7.centos                @mariadb                 537 k
 MariaDB-devel                 x86_64                10.1.37-1.el7.centos                @mariadb                  38 M
 MariaDB-server                x86_64                10.1.37-1.el7.centos                @mariadb                 452 M
 MariaDB-shared                x86_64                10.1.37-1.el7.centos                @mariadb                 6.5 M
依存性関連での削除をします:
 postfix                       x86_64                2:2.10.1-7.el7                      @anaconda                 12 M

トランザクションの要約
========================================================================================================================
削除  5 パッケージ (+1 個の依存関係のパッケージ)

インストール容量: 682 M
上記の処理を行います。よろしいでしょうか? [y/N] ■Nを押してEnterで停止

上記の例だと、postfixが依存性関連で削除されてしまうので、postfixの設定ファイルのバックアップが必要です。

環境により依存関連で削除されるパッケージが変わりますので、削除されるパッケージの確認と設定ファイルのバックアップは必ず行ってください。

データベースと設定ファイルのバックアップ

データベース全体のバックアップと、MariaDBの既存の設定ファイル、及び依存性関連で削除されてしまうpostfixの設定ファイルをバックアップします。

バックアップ用のディレクトリ作成

# mkdir /tmpMDB10.1
# mkdir /tmpMDB10.1/my.cnf.d
# mkdir /tmpMDB10.1/postfix

データベースのバックアップ

# mysqldump -u root -p --all-databases > /tmpMDB10.1/all_db_backup.sql

各種設定ファイルのコピー

# cp -r -a /etc/my.cnf /tmpMDB10.1/my.cnf
# cp -r -a /etc/my.cnf.d/* /tmpMDB10.1/my.cnf.d/
# cp -r -a /etc/postfix/* /tmpMDB10.1/postfix/

確認

# ls /tmpMDB10.1 -la
合計 488
drwxr-xr-x   4 root root   4096  1月 16 00:07 .
dr-xr-xr-x. 19 root root   4096  1月 16 00:06 ..
-rw-r--r--   1 root root 477138  1月 16 00:06 all_db_backup.sql
-rw-r--r--   1 root root    202 11月  1 06:54 my.cnf
drwxr-xr-x   2 root root   4096  1月 16 00:07 my.cnf.d
drwxr-xr-x   2 root root   4096  1月 16 00:07 postfix

バックアップ完了です。

MariaDBの停止

MariaDBを停止します。

# systemctl stop mariadb

MariaDBの削除

今度は「-y」オプションを付けて古いMariaDBを一気に削除します。

# yum -y remove MariaDB-*
読み込んだプラグイン:fastestmirror, langpacks
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-client.x86_64 0:10.1.37-1.el7.centos を 削除
---> パッケージ MariaDB-common.x86_64 0:10.1.37-1.el7.centos を 削除
---> パッケージ MariaDB-devel.x86_64 0:10.1.37-1.el7.centos を 削除
---> パッケージ MariaDB-server.x86_64 0:10.1.37-1.el7.centos を 削除
---> パッケージ MariaDB-shared.x86_64 0:10.1.37-1.el7.centos を 削除
--> 依存性の処理をしています: libmysqlclient.so.18()(64bit) のパッケージ: 2:postfix-2.10.1-7.el7.x86_64
--> 依存性の処理をしています: libmysqlclient.so.18(libmysqlclient_18)(64bit) のパッケージ: 2:postfix-2.10.1-7.el7.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ postfix.x86_64 2:2.10.1-7.el7 を 削除
--> 依存性解決を終了しました。

依存性を解決しました

========================================================================================================================
 Package                       アーキテクチャー      バージョン                          リポジトリー              容量
========================================================================================================================
削除中:
 MariaDB-client                x86_64                10.1.37-1.el7.centos                @mariadb                 172 M
 MariaDB-common                x86_64                10.1.37-1.el7.centos                @mariadb                 537 k
 MariaDB-devel                 x86_64                10.1.37-1.el7.centos                @mariadb                  38 M
 MariaDB-server                x86_64                10.1.37-1.el7.centos                @mariadb                 452 M
 MariaDB-shared                x86_64                10.1.37-1.el7.centos                @mariadb                 6.5 M
依存性関連での削除をします:
 postfix                       x86_64                2:2.10.1-7.el7                      @anaconda                 12 M

トランザクションの要約
========================================================================================================================
削除  5 パッケージ (+1 個の依存関係のパッケージ)

インストール容量: 682 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  削除中                  : MariaDB-devel-10.1.37-1.el7.centos.x86_64                                               1/6 
  削除中                  : MariaDB-server-10.1.37-1.el7.centos.x86_64                                              2/6 
警告: /etc/my.cnf.d/server.cnf は /etc/my.cnf.d/server.cnf.rpmsave として保存されました。
  削除中                  : MariaDB-client-10.1.37-1.el7.centos.x86_64                                              3/6 
  削除中                  : 2:postfix-2.10.1-7.el7.x86_64                                                           4/6 
  削除中                  : MariaDB-shared-10.1.37-1.el7.centos.x86_64                                              5/6 
  削除中                  : MariaDB-common-10.1.37-1.el7.centos.x86_64                                              6/6 
  検証中                  : MariaDB-devel-10.1.37-1.el7.centos.x86_64                                               1/6 
  検証中                  : MariaDB-client-10.1.37-1.el7.centos.x86_64                                              2/6 
  検証中                  : 2:postfix-2.10.1-7.el7.x86_64                                                           3/6 
  検証中                  : MariaDB-shared-10.1.37-1.el7.centos.x86_64                                              4/6 
  検証中                  : MariaDB-server-10.1.37-1.el7.centos.x86_64                                              5/6 
  検証中                  : MariaDB-common-10.1.37-1.el7.centos.x86_64                                              6/6 

削除しました:
  MariaDB-client.x86_64 0:10.1.37-1.el7.centos               MariaDB-common.x86_64 0:10.1.37-1.el7.centos              
  MariaDB-devel.x86_64 0:10.1.37-1.el7.centos                MariaDB-server.x86_64 0:10.1.37-1.el7.centos              
  MariaDB-shared.x86_64 0:10.1.37-1.el7.centos              

依存性の削除をしました:
  postfix.x86_64 2:2.10.1-7.el7                                                                                         

完了しました!

これでスッキリ綺麗になりました。(※postfixも同時に削除されています。)

MariaDB 10.3をインストール

MariaDB 10.3の「MariaDB-devel」「MariaDB-client」「 MariaDB-server」をインストールします。

# yum -y install MariaDB-devel MariaDB-client MariaDB-server
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * epel-debuginfo: ftp.iij.ad.jp
 * epel-source: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-client.x86_64 0:10.3.12-1.el7.centos を インストール
--> 依存性の処理をしています: MariaDB-common のパッケージ: MariaDB-client-10.3.12-1.el7.centos.x86_64
---> パッケージ MariaDB-devel.x86_64 0:10.3.12-1.el7.centos を インストール
---> パッケージ MariaDB-server.x86_64 0:10.3.12-1.el7.centos を インストール
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-common.x86_64 0:10.3.12-1.el7.centos を インストール
--> 依存性の処理をしています: MariaDB-compat のパッケージ: MariaDB-common-10.3.12-1.el7.centos.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-compat.x86_64 0:10.3.12-1.el7.centos を インストール
--> 依存性解決を終了しました。

依存性を解決しました

========================================================================================================================
 Package                      アーキテクチャー     バージョン                          リポジトリー                容量
========================================================================================================================
インストール中:
 MariaDB-client               x86_64               10.3.12-1.el7.centos                mariadb-main                53 M
 MariaDB-devel                x86_64               10.3.12-1.el7.centos                mariadb-main               7.0 M
 MariaDB-server               x86_64               10.3.12-1.el7.centos                mariadb-main               123 M
依存性関連でのインストールをします:
 MariaDB-common               x86_64               10.3.12-1.el7.centos                mariadb-main               166 k
 MariaDB-compat               x86_64               10.3.12-1.el7.centos                mariadb-main               2.8 M

トランザクションの要約
========================================================================================================================
インストール  3 パッケージ (+2 個の依存関係のパッケージ)

総ダウンロード容量: 187 M
インストール容量: 796 M
Downloading packages:
(1/5): MariaDB-10.3.12-centos73-x86_64-common.rpm                                                | 166 kB  00:00:02     
(2/5): MariaDB-10.3.12-centos73-x86_64-compat.rpm                                                | 2.8 MB  00:00:01     
(3/5): MariaDB-10.3.12-centos73-x86_64-devel.rpm                                                 | 7.0 MB  00:00:01     
(4/5): MariaDB-10.3.12-centos73-x86_64-client.rpm                                                |  53 MB  00:00:12     
(5/5): MariaDB-10.3.12-centos73-x86_64-server.rpm                                                | 123 MB  00:00:22     
------------------------------------------------------------------------------------------------------------------------
合計                                                                                    6.9 MB/s | 187 MB  00:00:27     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : MariaDB-compat-10.3.12-1.el7.centos.x86_64                                              1/5 
  インストール中          : MariaDB-common-10.3.12-1.el7.centos.x86_64                                              2/5 
  インストール中          : MariaDB-client-10.3.12-1.el7.centos.x86_64                                              3/5 
  インストール中          : MariaDB-server-10.3.12-1.el7.centos.x86_64                                              4/5 
  インストール中          : MariaDB-devel-10.3.12-1.el7.centos.x86_64                                               5/5 
  検証中                  : MariaDB-client-10.3.12-1.el7.centos.x86_64                                              1/5 
  検証中                  : MariaDB-devel-10.3.12-1.el7.centos.x86_64                                               2/5 
  検証中                  : MariaDB-server-10.3.12-1.el7.centos.x86_64                                              3/5 
  検証中                  : MariaDB-common-10.3.12-1.el7.centos.x86_64                                              4/5 
  検証中                  : MariaDB-compat-10.3.12-1.el7.centos.x86_64                                              5/5 

インストール:
  MariaDB-client.x86_64 0:10.3.12-1.el7.centos                MariaDB-devel.x86_64 0:10.3.12-1.el7.centos               
  MariaDB-server.x86_64 0:10.3.12-1.el7.centos               

依存性関連をインストールしました:
  MariaDB-common.x86_64 0:10.3.12-1.el7.centos               MariaDB-compat.x86_64 0:10.3.12-1.el7.centos              

完了しました!

MariaDB 10.3のインストールが完了しました。

MariaDBを起動し、自動起動をオンにします。

# systemctl start mariadb
# systemctl enable mariadb

削除されたパッケージの復元

古いMariaDBを削除した際に依存関係で同時に削除されたパッケージをインストールします。
※当方の環境ではpostfixが削除されましたので入れなおします。

# yum -y install postfix
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * epel-debuginfo: ftp.iij.ad.jp
 * epel-source: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ postfix.x86_64 2:2.10.1-7.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

========================================================================================================================
 Package                    アーキテクチャー          バージョン                          リポジトリー             容量
========================================================================================================================
インストール中:
 postfix                    x86_64                    2:2.10.1-7.el7                      base                    2.4 M

トランザクションの要約
========================================================================================================================
インストール  1 パッケージ

総ダウンロード容量: 2.4 M
インストール容量: 12 M
Downloading packages:
postfix-2.10.1-7.el7.x86_64.rpm                                                                  | 2.4 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : 2:postfix-2.10.1-7.el7.x86_64                                                           1/1 
  検証中                  : 2:postfix-2.10.1-7.el7.x86_64                                                           1/1 

インストール:
  postfix.x86_64 2:2.10.1-7.el7                                                                                         

完了しました!

postfixの設定ファイルをバックアップから復元(※全て上書き)

# cp -r -a /tmpMDB10.1/postfix/* /etc/postfix/

postfixの起動&自動起動設定

# systemctl start postfix
# systemctl enable postfix

【選択肢2】rpmでMariaDB-serverだけ削除してから10.3をyumでインストール

※この方法は、MariaDB 10.1から10.3に無理やりyum updateを行ったら「MariaDB-server」だけアップデートに失敗し、その際に表示されていたエラーに書かれていた手順を参考に行います。

以下がエラーの内容です。

A MySQL or MariaDB server package (MariaDB-server-10.1.37-1.el7.centos.x86_64) is installed.
Upgrading directly from MySQL 10.1 to MariaDB 10.3 may not be safe in all cases. 
A manual dump and restore using mysqldump is recommended. It is important to review the MariaDB manual's Upgrading section for version-specific incompatibilities.

A manual upgrade is required.

- Ensure that you have a complete, working backup of your data and my.cnf files
- Shut down the MySQL server cleanly
- Remove the existing MySQL packages. Usually this command will list the packages you should remove:

rpm -qa | grep -i '^mysql-'

You may choose to use 'rpm --nodeps -ev <package-name>' to remove the package which contains the mysqlclient shared library. The library will be reinstalled by the MariaDB-shared package.

- Install the new MariaDB packages supplied by MariaDB Foundation
- Ensure that the MariaDB server is started
- Run the 'mysql_upgrade' program

This is a brief description of the upgrade process. Important details can be found in the MariaDB manual, in the Upgrading section.

MySQLまたはMariaDBサーバーパッケージ(MariaDB-server-10.1.37-1.el7.centos.x86_64)がインストールされています。
MySQL 10.1からMariaDB 10.3に直接アップグレードすることは、すべての場合において安全ではないかもしれません。
手動ダンプおよびmysqldumpを使用した復元をお勧めします。 MariaDBマニュアルのバージョン固有の非互換性については、アップグレードのセクションを参照することが重要です。

手動アップグレードが必要です。

– データとmy.cnfファイルの完全な作業用バックアップがあることを確認してください。
– MySQLサーバをきれいにシャットダウンする
– 既存のMySQLパッケージを削除します。通常このコマンドは削除すべきパッケージを一覧表示します。

rpm -qa | grep -i ‘^ mysql-‘

mysqlclient共有ライブラリを含むパッケージを削除するには、 ‘rpm –nodeps -ev <パッケージ名>’を使用することを選択できます。このライブラリはMariaDB共有パッケージによって再インストールされます。

– MariaDB Foundationが提供する新しいMariaDBパッケージをインストールします。
– MariaDBサーバーが起動していることを確認します。
– ‘mysql_upgrade’プログラムを実行してください。

これはアップグレードプロセスの簡単な説明です。重要な詳細はMariaDBのマニュアルの「アップグレード」セクションにあります。

この手順で進めていきます。

データベースと設定ファイルのバックアップ

データベース全体のバックアップと、MariaDBの既存の設定ファイルをバックアップします。

バックアップ用のディレクトリ作成

# mkdir /tmpMDB10.1
# mkdir /tmpMDB10.1/my.cnf.d

データベースのバックアップ

# mysqldump -u root -p --all-databases > /tmpMDB10.1/all_db_backup.sql

各種設定ファイルのコピー

# cp -r -a /etc/my.cnf /tmpMDB10.1/my.cnf
# cp -r -a /etc/my.cnf.d/* /tmpMDB10.1/my.cnf.d/

MariaDBの停止

MariaDBを停止します。

# systemctl stop mariadb

削除するMariaDB-serverの確認

削除するMariaDB-serverの詳細を確認します。

# rpm -qa | grep -i '^mariadb-'
MariaDB-devel-10.1.37-1.el7.centos.x86_64
MariaDB-common-10.1.37-1.el7.centos.x86_64
MariaDB-client-10.1.37-1.el7.centos.x86_64
MariaDB-server-10.1.37-1.el7.centos.x86_64
MariaDB-shared-10.1.37-1.el7.centos.x86_64

MariaDB-serverの削除

「MariaDB-server-10.1.37-1.el7.centos.x86_64」だけを「rpm –nodeps -ev」で削除します。

# rpm --nodeps -ev MariaDB-server-10.1.37-1.el7.centos.x86_64
パッケージの準備中...
MariaDB-server-10.1.37-1.el7.centos.x86_64

正常に削除されたかの確認

# rpm -qa | grep -i '^mariadb-'
MariaDB-devel-10.1.37-1.el7.centos.x86_64
MariaDB-common-10.1.37-1.el7.centos.x86_64
MariaDB-client-10.1.37-1.el7.centos.x86_64
MariaDB-shared-10.1.37-1.el7.centos.x86_64

正常に「MariaDB-server」だけ削除されました。

yumでMariaDB 10.3をまとめてインストール

yumで「MariaDB-devel」「MariaDB-common」「MariaDB-client」「MariaDB-server」「MariaDB-shared」の10.3をまとめてインストール(上書きインストール)します。

# yum -y install MariaDB-devel MariaDB-common MariaDB-client MariaDB-server MariaDB-shared
読み込んだプラグイン:fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink                                                                           | 8.7 kB  00:00:00     
epel-debuginfo/x86_64/metalink                                                                 | 8.9 kB  00:00:00     
epel-source/x86_64/metalink                                                                    | 8.6 kB  00:00:00     
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * epel-debuginfo: ftp.iij.ad.jp
 * epel-source: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
base                                                                                           | 3.6 kB  00:00:00     
epel                                                                                           | 4.7 kB  00:00:00     
epel-debuginfo                                                                                 | 3.0 kB  00:00:00     
epel-source                                                                                    | 3.5 kB  00:00:00     
extras                                                                                         | 3.4 kB  00:00:00     
mariadb                                                                                        | 2.9 kB  00:00:00     
mariadb-main                                                                                   | 2.9 kB  00:00:00     
mariadb-maxscale                                                                               | 2.4 kB  00:00:00     
mariadb-tools                                                                                  | 2.9 kB  00:00:00     
updates                                                                                        | 3.4 kB  00:00:00     
(1/14): base/7/x86_64/group_gz                                                                 | 166 kB  00:00:00     
(2/14): epel/x86_64/group_gz                                                                   |  88 kB  00:00:00     
(3/14): epel/x86_64/updateinfo                                                                 | 952 kB  00:00:00     
(4/14): epel-debuginfo/x86_64/primary_db                                                       | 882 kB  00:00:00     
(5/14): epel-source/x86_64/updateinfo                                                          | 952 kB  00:00:00     
(6/14): epel/x86_64/primary_db                                                                 | 6.6 MB  00:00:00     
(7/14): extras/7/x86_64/primary_db                                                             | 156 kB  00:00:00     
(8/14): base/7/x86_64/primary_db                                                               | 6.0 MB  00:00:00     
(9/14): epel-source/x86_64/primary_db                                                          | 2.3 MB  00:00:00     
(10/14): updates/7/x86_64/primary_db                                                           | 1.3 MB  00:00:00     
(11/14): mariadb/primary_db                                                                    |  66 kB  00:00:00     
(12/14): mariadb-maxscale/7/x86_64/primary_db                                                  | 6.7 kB  00:00:01     
(13/14): mariadb-tools/7/x86_64/primary_db                                                     |  11 kB  00:00:01     
(14/14): mariadb-main/7/x86_64/primary_db                                                      |  50 kB  00:00:01     
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-client.x86_64 0:10.1.37-1.el7.centos を 更新
---> パッケージ MariaDB-client.x86_64 0:10.3.12-1.el7.centos を アップデート
---> パッケージ MariaDB-common.x86_64 0:10.1.37-1.el7.centos を 更新
---> パッケージ MariaDB-common.x86_64 0:10.3.12-1.el7.centos を アップデート
--> 依存性の処理をしています: MariaDB-compat のパッケージ: MariaDB-common-10.3.12-1.el7.centos.x86_64
---> パッケージ MariaDB-devel.x86_64 0:10.1.37-1.el7.centos を 更新
---> パッケージ MariaDB-devel.x86_64 0:10.3.12-1.el7.centos を アップデート
---> パッケージ MariaDB-server.x86_64 0:10.3.12-1.el7.centos を インストール
---> パッケージ MariaDB-shared.x86_64 0:10.1.37-1.el7.centos を 更新
---> パッケージ MariaDB-shared.x86_64 0:10.3.12-1.el7.centos を アップデート
--> トランザクションの確認を実行しています。
---> パッケージ MariaDB-compat.x86_64 0:10.3.12-1.el7.centos を インストール
--> 依存性解決を終了しました。

依存性を解決しました

======================================================================================================================
 Package                     アーキテクチャー    バージョン                           リポジトリー               容量
======================================================================================================================
インストール中:
 MariaDB-server              x86_64              10.3.12-1.el7.centos                 mariadb-main              123 M
更新します:
 MariaDB-client              x86_64              10.3.12-1.el7.centos                 mariadb-main               53 M
 MariaDB-common              x86_64              10.3.12-1.el7.centos                 mariadb-main              166 k
 MariaDB-devel               x86_64              10.3.12-1.el7.centos                 mariadb-main              7.0 M
 MariaDB-shared              x86_64              10.3.12-1.el7.centos                 mariadb-main              402 k
依存性関連でのインストールをします:
 MariaDB-compat              x86_64              10.3.12-1.el7.centos                 mariadb-main              2.8 M

トランザクションの要約
======================================================================================================================
インストール  1 パッケージ (+1 個の依存関係のパッケージ)
更新          4 パッケージ

総ダウンロード容量: 187 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/6): MariaDB-10.3.12-centos73-x86_64-common.rpm                                              | 166 kB  00:00:01     
(2/6): MariaDB-10.3.12-centos73-x86_64-compat.rpm                                              | 2.8 MB  00:00:01     
(3/6): MariaDB-10.3.12-centos73-x86_64-devel.rpm                                               | 7.0 MB  00:00:01     
(4/6): MariaDB-10.3.12-centos73-x86_64-client.rpm                                              |  53 MB  00:00:10     
(5/6): MariaDB-10.3.12-centos73-x86_64-shared.rpm                                              | 402 kB  00:00:00     
(6/6): MariaDB-10.3.12-centos73-x86_64-server.rpm                                              | 123 MB  00:00:19     
----------------------------------------------------------------------------------------------------------------------
合計                                                                                  7.7 MB/s | 187 MB  00:00:24     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告: RPMDB は yum 以外で変更されました。
  更新します              : MariaDB-common-10.3.12-1.el7.centos.x86_64                                           1/10 
  インストール中          : MariaDB-compat-10.3.12-1.el7.centos.x86_64                                           2/10 
  更新します              : MariaDB-client-10.3.12-1.el7.centos.x86_64                                           3/10 
  インストール中          : MariaDB-server-10.3.12-1.el7.centos.x86_64                                           4/10 
  更新します              : MariaDB-devel-10.3.12-1.el7.centos.x86_64                                            5/10 
  更新します              : MariaDB-shared-10.3.12-1.el7.centos.x86_64                                           6/10 
  整理中                  : MariaDB-devel-10.1.37-1.el7.centos.x86_64                                            7/10 
  整理中                  : MariaDB-shared-10.1.37-1.el7.centos.x86_64                                           8/10 
  整理中                  : MariaDB-client-10.1.37-1.el7.centos.x86_64                                           9/10 
  整理中                  : MariaDB-common-10.1.37-1.el7.centos.x86_64                                          10/10 
  検証中                  : MariaDB-devel-10.3.12-1.el7.centos.x86_64                                            1/10 
  検証中                  : MariaDB-client-10.3.12-1.el7.centos.x86_64                                           2/10 
  検証中                  : MariaDB-shared-10.3.12-1.el7.centos.x86_64                                           3/10 
  検証中                  : MariaDB-compat-10.3.12-1.el7.centos.x86_64                                           4/10 
  検証中                  : MariaDB-server-10.3.12-1.el7.centos.x86_64                                           5/10 
  検証中                  : MariaDB-common-10.3.12-1.el7.centos.x86_64                                           6/10 
  検証中                  : MariaDB-devel-10.1.37-1.el7.centos.x86_64                                            7/10 
  検証中                  : MariaDB-client-10.1.37-1.el7.centos.x86_64                                           8/10 
  検証中                  : MariaDB-shared-10.1.37-1.el7.centos.x86_64                                           9/10 
  検証中                  : MariaDB-common-10.1.37-1.el7.centos.x86_64                                          10/10 

インストール:
  MariaDB-server.x86_64 0:10.3.12-1.el7.centos                                                                        

依存性関連をインストールしました:
  MariaDB-compat.x86_64 0:10.3.12-1.el7.centos                                                                        

更新:
  MariaDB-client.x86_64 0:10.3.12-1.el7.centos              MariaDB-common.x86_64 0:10.3.12-1.el7.centos             
  MariaDB-devel.x86_64 0:10.3.12-1.el7.centos               MariaDB-shared.x86_64 0:10.3.12-1.el7.centos             

完了しました!

確認

# rpm -qa | grep -i '^mariadb-'
MariaDB-common-10.3.12-1.el7.centos.x86_64
MariaDB-devel-10.3.12-1.el7.centos.x86_64
MariaDB-compat-10.3.12-1.el7.centos.x86_64
MariaDB-server-10.3.12-1.el7.centos.x86_64
MariaDB-shared-10.3.12-1.el7.centos.x86_64
MariaDB-client-10.3.12-1.el7.centos.x86_64

正常にインストールが成功しました。

MariaDBを起動し、自動起動をオンにします。

# systemctl start mariadb
# systemctl enable mariadb

MariaDB 10.3の初期設定

mariadb-secure-installationの実行

【選択肢1】又は【選択肢2】でMariaDB 10.3のインストールが完了したら、不要なユーザーや不要なデータベースを削除してセキュリティを高める「mariadb-secure-installation」を実行します。

※従来の「mysql_secure_installation」は「mariadb-secure-installation」に変更になりました。
mysql_secure_installationを実行した際に「bash: mysql_secure_installation: コマンドが見つかりません」と表示された場合は、代わりに「mariadb-secure-installation」を実行してください。
# mariadb-secure-installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): ■従来のMariaDBのrootパスワードを入力
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n ■unix_socketは利用しない。
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] n ■パスワードの変更はしない。
 ... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y ■匿名のユーザーを削除します。
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y ■リモートからのrootログインを拒否します。
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y ■Test用のデータベースを削除します。
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y ■設定をリロードします。
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

設定ファイルを編集

MariaDB 10.3用の設定ファイル「/etc/my.cnf.d/server.cnf」が新規作成されているので、事前にバックアップした設定ファイルからvi等で必要な情報を記載して編集します。

確認したところ、「server.cnf.bak」というファイルが作成されてMariaDB 10.1用の設定ファイルは自動でバックアップされていました。

「/etc/my.cnf」にもバックアップから必要な設定をvi等で追記します。

設定ファイルの編集が終わったらMariaDBを再起動します。

# systemctl restart mariadb

mysql_upgradeの実行

アップグレード後の整合性をチェックするために「mysql_upgrade」を実行します。

# mysql_upgrade -u root -p
Enter password: ■パスワード入力
Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats                                 OK
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.gtid_slave_pos                               OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.index_stats                                  OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.roles_mapping                                OK
mysql.servers                                      OK
mysql.table_stats                                  OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Phase 2/7: Installing used storage engines... Skipped
Phase 3/7: Fixing views
Phase 4/7: Running 'mysql_fix_privilege_tables'
Phase 5/7: Fixing table and database names
Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
performance_schema
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK

全てOKと出れば問題ありません。

※文字セット(charset)をutf8mb4に変更したい場合は以下のページで手順を解説していますのでご覧ください。

最後に再起動

最後に念のために各サービスを再起動します。

# systemctl restart mariadb

■Nginxの場合
# systemctl restart nginx
# systemctl restart php-fpm

■Apacheの場合
# systemctl restart httpd

いっそのことサーバ全体を再起動したほうが気持ちイイかもしれません。

# shutdown -r now

これでMariaDBのアップグレード作業は全て完了です。
お疲れ様でした。

以上で解決です。

タイトルとURLをコピーしました