EC2 Amazon Linux2のmariadb リポジトリが5.5
コンテンツ
Amazon Linux2 のyum リポジトリにあるmariadb のバージョンは5.5のままで、yum install でインストール実行した場合に古いmariadbがインストールされます。
Next.jsでWebサービス開発中にて、ORマッパーのPrismaが古いmariadbに対応していないのでアップデートを行います。
古いMariaDBを削除
mariadb プロセスを停止
mariadbプロセスを停止します。
$ sudo systemctl stop mariadb
mariadbを削除
mariadbを削除します。
$ sudo yum remove mariadb
$ sudo yum remove mariadb-devel
$ sudo yum remove mariadb-libs
[ec2-user@ip-************ ~]$ sudo yum remove mariadb
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.68-1.amzn2 will be erased
--> Processing Dependency: mariadb(x86-64) = 1:5.5.68-1.amzn2 for package: 1:mariadb-server-5.5.68-1.amzn2.x86_64
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.68-1.amzn2 will be erased
--> Finished Dependency Resolution
amzn2-core/2/x86_64 | 3.7 kB 00:00:00
mariadb | 3.4 kB 00:00:00
mariadb/updateinfo | 5.4 kB 00:00:00
mariadb/primary_db | 67 kB 00:00:00
Dependencies Resolved
=======================================================================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================================================================
Removing:
mariadb x86_64 1:5.5.68-1.amzn2 @amzn2-core 49 M
Removing for dependencies:
mariadb-server x86_64 1:5.5.68-1.amzn2 @amzn2-core 58 M
Transaction Summary
=======================================================================================================================================================================================================================
Remove 1 Package (+1 Dependent package)
Installed size: 106 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : 1:mariadb-server-5.5.68-1.amzn2.x86_64 1/2
warning: /var/log/mariadb/mariadb.log saved as /var/log/mariadb/mariadb.log.rpmsave
Erasing : 1:mariadb-5.5.68-1.amzn2.x86_64 2/2
Verifying : 1:mariadb-server-5.5.68-1.amzn2.x86_64 1/2
Verifying : 1:mariadb-5.5.68-1.amzn2.x86_64 2/2
Removed:
mariadb.x86_64 1:5.5.68-1.amzn2
Dependency Removed:
mariadb-server.x86_64 1:5.5.68-1.amzn2
Complete!
mariadbが削除されました。
mariadb をyum リポジトリに追加
デフォルトのリポジトリにはmariadbの最新版リポジトリがありません。
yumリポジトリに追加します。> mariadb 10.6
リポジトリファイル(mariadb.repo)がない場合は作成します。
$ sudo vi /etc/yum.repos.d/mariadb.repo
Amazon Linux2 はcentos7 ベースなので、centos7 のリポジトリを追加します。
# mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.6/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
mariadb 10.6 をインストール
yum install でmariadb 10.6をインストールします。
$ sudo yum install -y mariadb-server mariadb-client MariaDB-shared MariaDB-devel
MariaDB-sharedは、依存関係エラーが発生した場合に MariaDB-sharedをインストールすることでエラーが解消されました。
[ec2-user@ip-************* ~]$ sudo yum install -y mariadb-server mariadb-client MariaDB-shared MariaDB-devel
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
1 packages excluded due to repository priority protections
Package mariadb-server is obsoleted by MariaDB-server, trying to install MariaDB-server-10.6.5-1.el7.centos.x86_64 instead
No package mariadb-client available.
* Maybe you meant: MariaDB-client
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-devel.x86_64 0:10.6.5-1.el7.centos will be installed
--> Processing Dependency: MariaDB-common for package: MariaDB-devel-10.6.5-1.el7.centos.x86_64
---> Package MariaDB-server.x86_64 0:10.6.5-1.el7.centos will be installed
--> Processing Dependency: MariaDB-client >= 10.6.1 for package: MariaDB-server-10.6.5-1.el7.centos.x86_64
--> Processing Dependency: libpmem.so.1(LIBPMEM_1.0)(64bit) for package: MariaDB-server-10.6.5-1.el7.centos.x86_64
--> Processing Dependency: galera-4 for package: MariaDB-server-10.6.5-1.el7.centos.x86_64
--> Processing Dependency: libpmem.so.1()(64bit) for package: MariaDB-server-10.6.5-1.el7.centos.x86_64
---> Package MariaDB-shared.x86_64 0:10.6.5-1.el7.centos will be installed
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.6.5-1.el7.centos will be installed
--> Processing Dependency: libncurses.so.5()(64bit) for package: MariaDB-client-10.6.5-1.el7.centos.x86_64
--> Processing Dependency: libtinfo.so.5()(64bit) for package: MariaDB-client-10.6.5-1.el7.centos.x86_64
---> Package MariaDB-common.x86_64 0:10.6.5-1.el7.centos will be installed
--> Processing Dependency: MariaDB-compat for package: MariaDB-common-10.6.5-1.el7.centos.x86_64
---> Package galera-4.x86_64 0:26.4.9-1.el7.centos will be installed
--> Processing Dependency: socat for package: galera-4-26.4.9-1.el7.centos.x86_64
--> Processing Dependency: libboost_program_options-mt.so.1.53.0()(64bit) for package: galera-4-26.4.9-1.el7.centos.x86_64
---> Package libpmem.x86_64 0:1.3-3.amzn2 will be installed
--> Running transaction check
---> Package MariaDB-compat.x86_64 0:10.6.5-1.el7.centos will be installed
---> Package boost-program-options.x86_64 0:1.53.0-27.amzn2.0.5 will be installed
---> Package ncurses-compat-libs.x86_64 0:6.0-8.20170212.amzn2.1.3 will be installed
---> Package socat.x86_64 0:1.7.3.2-2.amzn2.0.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================================================================
Installing:
MariaDB-devel x86_64 10.6.5-1.el7.centos mariadb 8.1 M
MariaDB-server x86_64 10.6.5-1.el7.centos mariadb 25 M
MariaDB-shared x86_64 10.6.5-1.el7.centos mariadb 113 k
Installing for dependencies:
MariaDB-client x86_64 10.6.5-1.el7.centos mariadb 14 M
MariaDB-common x86_64 10.6.5-1.el7.centos mariadb 81 k
MariaDB-compat x86_64 10.6.5-1.el7.centos mariadb 2.2 M
boost-program-options x86_64 1.53.0-27.amzn2.0.5 amzn2-core 161 k
galera-4 x86_64 26.4.9-1.el7.centos mariadb 9.6 M
libpmem x86_64 1.3-3.amzn2 amzn2-core 36 k
ncurses-compat-libs x86_64 6.0-8.20170212.amzn2.1.3 amzn2-core 308 k
socat x86_64 1.7.3.2-2.amzn2.0.1 amzn2-core 291 k
Transaction Summary
=======================================================================================================================================================================================================================
Install 3 Packages (+8 Dependent packages)
Total download size: 60 M
Installed size: 276 M
Downloading packages:
warning: /var/cache/yum/x86_64/2/mariadb/packages/MariaDB-common-10.6.5-1.el7.centos.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY ] 0.0 B/s | 48 kB --:--:-- ETA
Public key for MariaDB-common-10.6.5-1.el7.centos.x86_64.rpm is not installed
(1/11): MariaDB-common-10.6.5-1.el7.centos.x86_64.rpm | 81 kB 00:00:00
(2/11): MariaDB-compat-10.6.5-1.el7.centos.x86_64.rpm | 2.2 MB 00:00:03
(3/11): MariaDB-devel-10.6.5-1.el7.centos.x86_64.rpm | 8.1 MB 00:00:01
(4/11): MariaDB-client-10.6.5-1.el7.centos.x86_64.rpm | 14 MB 00:00:06
(5/11): boost-program-options-1.53.0-27.amzn2.0.5.x86_64.rpm | 161 kB 00:00:00
(6/11): MariaDB-shared-10.6.5-1.el7.centos.x86_64.rpm | 113 kB 00:00:00
(7/11): libpmem-1.3-3.amzn2.x86_64.rpm | 36 kB 00:00:00
(8/11): ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64.rpm | 308 kB 00:00:00
(9/11): socat-1.7.3.2-2.amzn2.0.1.x86_64.rpm | 291 kB 00:00:00
(10/11): galera-4-26.4.9-1.el7.centos.x86_64.rpm | 9.6 MB 00:00:01
(11/11): MariaDB-server-10.6.5-1.el7.centos.x86_64.rpm | 25 MB 00:00:03
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 6.6 MB/s | 60 MB 00:00:09
Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Importing GPG key 0x1BB943DB:
Userid : "MariaDB Package Signing Key <package-signing-key@mariadb.org>"
Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db
From : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : MariaDB-compat-10.6.5-1.el7.centos.x86_64 1/11
Installing : MariaDB-common-10.6.5-1.el7.centos.x86_64 2/11
Installing : libpmem-1.3-3.amzn2.x86_64 3/11
Installing : socat-1.7.3.2-2.amzn2.0.1.x86_64 4/11
Installing : boost-program-options-1.53.0-27.amzn2.0.5.x86_64 5/11
Installing : galera-4-26.4.9-1.el7.centos.x86_64 6/11
Installing : ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64 7/11
Installing : MariaDB-client-10.6.5-1.el7.centos.x86_64 8/11
Installing : MariaDB-server-10.6.5-1.el7.centos.x86_64 9/11
Installing : MariaDB-shared-10.6.5-1.el7.centos.x86_64 10/11
Installing : MariaDB-devel-10.6.5-1.el7.centos.x86_64 11/11
Verifying : ncurses-compat-libs-6.0-8.20170212.amzn2.1.3.x86_64 1/11
Verifying : MariaDB-common-10.6.5-1.el7.centos.x86_64 2/11
Verifying : boost-program-options-1.53.0-27.amzn2.0.5.x86_64 3/11
Verifying : MariaDB-shared-10.6.5-1.el7.centos.x86_64 4/11
Verifying : socat-1.7.3.2-2.amzn2.0.1.x86_64 5/11
Verifying : MariaDB-server-10.6.5-1.el7.centos.x86_64 6/11
Verifying : galera-4-26.4.9-1.el7.centos.x86_64 7/11
Verifying : MariaDB-compat-10.6.5-1.el7.centos.x86_64 8/11
Verifying : MariaDB-devel-10.6.5-1.el7.centos.x86_64 9/11
Verifying : MariaDB-client-10.6.5-1.el7.centos.x86_64 10/11
Verifying : libpmem-1.3-3.amzn2.x86_64 11/11
Installed:
MariaDB-devel.x86_64 0:10.6.5-1.el7.centos MariaDB-server.x86_64 0:10.6.5-1.el7.centos MariaDB-shared.x86_64 0:10.6.5-1.el7.centos
Dependency Installed:
MariaDB-client.x86_64 0:10.6.5-1.el7.centos MariaDB-common.x86_64 0:10.6.5-1.el7.centos MariaDB-compat.x86_64 0:10.6.5-1.el7.centos boost-program-options.x86_64 0:1.53.0-27.amzn2.0.5
galera-4.x86_64 0:26.4.9-1.el7.centos libpmem.x86_64 0:1.3-3.amzn2 ncurses-compat-libs.x86_64 0:6.0-8.20170212.amzn2.1.3 socat.x86_64 0:1.7.3.2-2.amzn2.0.1
Complete!
MariaDBを起動
Mariadbを起動します。
$ sudo systemctl start mariadb
自動起動設定をします。
$ sudo systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
エラー対応
mariadb操作時に下記エラーが発生する場合、mysql_upgradeを実行します。
Error: Column count of mysql.proc is wrong. Expected 21, found 20. Created with MariaDB 50564, now running 100605. Please use mariadb-upgrade to fix this error
mysql_upgrade実行
$ mysql_upgrade -u root -p