1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Amazon RDS for MySQL】EC2でmysqlshコマンドが実行できるようにする

Posted at

概要

AWSから [アクションが必要です] Amazon RDS MySQL 8.0 は、2026 年 7 月 31 日に標準サポートを終了する予定です というメールが来ました。

ざっくり言うと、「あなたが使ってる MySQL 8.0 はEOLになるからメジャーバージョンアップグレードしてね、しない場合は延長サポートで最大3年間猶予できるけどその分お金かかるよ」という内容です。

というわけで、AWSの公式情報に従って、MySQL 8.0 から MySQL 8.4 へアップグレードしたいと思います。

アップグレードをするにあたり、MySQLが出している Upgrade Checker Utility というツールがあるので、それを利用することにしました。

mysqlsh コマンドが使えるようにするだけなのですが、サクッとはいかなかったので備忘録として記録を残します。

環境

  • Amazon EC2
    • OS: Amazon Linux 2023
    • version: 2023.6.20250317 → 2023.7.20250623
  • Amazon RDS for MySQL
    • version: MySQL 8.0.40

MySQL Shellの導入

AWSの公式ブログに情報があるので正確な内容はこちらを読んでもらいたいのですが、英語だから読むのがめんどくせぇ!って方にざっくり内容を説明すると、「RDSと同じVPC内にEC2を立てて、そのEC2が立ち上がる時にbash scriptを使って mysqlsh を使えるようにして util.checkForServerUpgrade を実行、実行結果をS3に送る」という内容です。

RDSが複数台あるような環境であれば、公式ブログ通りにやるのが良いと思いますが、私の環境ではRDSは1台なので、既存のEC2から mysqlsh を使えるようにしたいと思います。

手順

手順は基本的に公式ブログのbashの内容を手動で叩く感じです。

※一部変更しています

1. MySQL 8.4 のリポジトリを追加

$ sudo dnf localinstall -y https://dev.mysql.com/get/mysql84-community-release-el9-2.noarch.rpm

Dependencies resolved.
====================================================================================================================================
 Package                                     Architecture             Version                  Repository                      Size
====================================================================================================================================
Installing:
 mysql84-community-release                   noarch                   el9-2                    @commandline                    14 k

Transaction Summary
====================================================================================================================================
Install  1 Package

Total size: 14 k
Installed size: 16 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                            1/1 
  Installing       : mysql84-community-release-el9-2.noarch                                                                     1/1 
  Running scriptlet: mysql84-community-release-el9-2.noarch                                                                     1/1 
  Verifying        : mysql84-community-release-el9-2.noarch                                                                     1/1 
====================================================================================================================================

2. 有効なリポジトリを確認

MySQL 8.4 が有効になっているか念のため確認します。

$ dnf repolist enabled | grep mysql
mysql-8.4-lts-community         MySQL 8.4 LTS Community Server
mysql-connectors-community      MySQL Connectors Community
mysql-tools-8.4-lts-community   MySQL Tools 8.4 LTS Community

3. まずは mysql-community-client をインストール

$ sudo dnf clean all
$ sudo dnf update -y

MySQL Connectors Community                                                                          6.9  B/s |  10  B     00:01    
Errors during downloading metadata for repository 'mysql-connectors-community':
  - Status code: 404 for https://repo.mysql.com/yum/mysql-connectors-community/el/2023.6.20250317/x86_64/repodata/repomd.xml (IP: 23.215.253.43)
Error: Failed to download metadata for repo 'mysql-connectors-community': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
MySQL 8.4 LTS Community Server                                                                      7.7  B/s |  10  B     00:01    
Errors during downloading metadata for repository 'mysql-8.4-lts-community':
  - Status code: 404 for https://repo.mysql.com/yum/mysql-8.4-community/el/2023.6.20250317/x86_64/repodata/repomd.xml (IP: 23.215.253.43)
Error: Failed to download metadata for repo 'mysql-8.4-lts-community': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
MySQL Tools 8.4 LTS Community                                                                       3.8  B/s |  10  B     00:02    
Errors during downloading metadata for repository 'mysql-tools-8.4-lts-community':
  - Status code: 404 for https://repo.mysql.com/yum/mysql-tools-8.4-community/el/2023.6.20250317/x86_64/repodata/repomd.xml (IP: 23.215.253.43)
Error: Failed to download metadata for repo 'mysql-tools-8.4-lts-community': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: mysql-connectors-community, mysql-8.4-lts-community, mysql-tools-8.4-lts-community
====================================================================================================================================
Dependencies resolved.
Nothing to do.
Complete!

何やらエラーになってしまったので原因を探ります。

404が出ている https://repo.mysql.com/yum/mysql-connectors-community/el/ を見ると当然ながら 2023.6.20250317 は存在しません。

この数字、見覚えがありますねぇ。そうです、AL2023のバージョンです。

$ less /etc/yum.repos.d/mysql-community.repo

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://repo.mysql.com/yum/mysql-connectors-community/el/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2023
       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

RHEL9のパッケージを利用しているので、$releasever9 が入って欲しいのにAL2023のバージョンが入ってしまうのが原因っぽいので対応します。

$ sudo vi /etc/dnf/vars/rhel_releasever
9

$ sudo sed -i "s/\$releasever/\$rhel_releasever/g" /etc/yum.repos.d/mysql-community.repo

$ sudo dnf clean all
17 files removed

$ sudo dnf update -y
Amazon Linux 2023 repository                                                                         67 MB/s |  34 MB     00:00    
Amazon Linux 2023 Kernel Livepatch repository                                                       115 kB/s |  19 kB     00:00    
MySQL Connectors Community                                                                          1.1 MB/s |  90 kB     00:00    
MySQL 8.4 LTS Community Server                                                                       13 MB/s | 1.2 MB     00:00    
MySQL Tools 8.4 LTS Community                                                                       6.9 MB/s | 659 kB     00:00    
====================================================================================================================================
Dependencies resolved.
Nothing to do.
Complete!

エラーが消えました。では mysql-community-client をインストールします。

$ sudo dnf install -y mysql-community-client

Dependencies resolved.
====================================================================================================================================
 Package                                    Architecture       Version                    Repository                           Size
====================================================================================================================================
Installing:
 mysql-community-client                     x86_64             8.4.6-1.el9                mysql-8.4-lts-community             3.1 M
Installing dependencies:
 mysql-community-client-plugins             x86_64             8.4.6-1.el9                mysql-8.4-lts-community             1.5 M
 mysql-community-common                     x86_64             8.4.6-1.el9                mysql-8.4-lts-community             578 k
 mysql-community-libs                       x86_64             8.4.6-1.el9                mysql-8.4-lts-community             1.5 M

Transaction Summary
====================================================================================================================================
Install  4 Packages

Total download size: 6.6 M
Installed size: 95 M
Downloading Packages:
(1/4): mysql-community-common-8.4.6-1.el9.x86_64.rpm                                                 12 MB/s | 578 kB     00:00    
(2/4): mysql-community-client-plugins-8.4.6-1.el9.x86_64.rpm                                         20 MB/s | 1.5 MB     00:00    
(3/4): mysql-community-libs-8.4.6-1.el9.x86_64.rpm                                                   45 MB/s | 1.5 MB     00:00    
(4/4): mysql-community-client-8.4.6-1.el9.x86_64.rpm                                                 30 MB/s | 3.1 MB     00:00    
------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                63 MB/s | 6.6 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                            1/1 
  Installing       : mysql-community-client-plugins-8.4.6-1.el9.x86_64                                                          1/4 
  Installing       : mysql-community-common-8.4.6-1.el9.x86_64                                                                  2/4 
  Installing       : mysql-community-libs-8.4.6-1.el9.x86_64                                                                    3/4 
  Running scriptlet: mysql-community-libs-8.4.6-1.el9.x86_64                                                                    3/4 
  Installing       : mysql-community-client-8.4.6-1.el9.x86_64                                                                  4/4 
  Running scriptlet: mysql-community-client-8.4.6-1.el9.x86_64                                                                  4/4 
  Verifying        : mysql-community-client-8.4.6-1.el9.x86_64                                                                  1/4 
  Verifying        : mysql-community-client-plugins-8.4.6-1.el9.x86_64                                                          2/4 
  Verifying        : mysql-community-common-8.4.6-1.el9.x86_64                                                                  3/4 
  Verifying        : mysql-community-libs-8.4.6-1.el9.x86_64                                                                    4/4 
====================================================================================================================================

Installed:
  mysql-community-client-8.4.6-1.el9.x86_64                    mysql-community-client-plugins-8.4.6-1.el9.x86_64                   
  mysql-community-common-8.4.6-1.el9.x86_64                    mysql-community-libs-8.4.6-1.el9.x86_64                             

Complete!

$ mysql --version
mysql  Ver 8.4.6 for Linux on x86_64 (MySQL Community Server - GPL)

4. mysql-shell をインストールする

$ sudo dnf install -y mysql-shell

Dependencies resolved.

 Problem: cannot install the best candidate for the job
  - nothing provides libcrypto.so.3(OPENSSL_3.2.0)(64bit) needed by mysql-shell-8.4.6-1.el9.x86_64 from mysql-tools-8.4-lts-community
====================================================================================================================================
 Package                    Architecture        Version                            Repository                                  Size
====================================================================================================================================
Installing:
 mysql-shell                x86_64              8.4.4-1.el9                        mysql-tools-8.4-lts-community               82 M
Installing dependencies:
 libssh                     x86_64              0.10.6-1.amzn2023.0.1              amazonlinux                                217 k
 libssh-config              noarch              0.10.6-1.amzn2023.0.1              amazonlinux                                 11 k
Skipping packages with broken dependencies:
 mysql-shell                x86_64              8.4.6-1.el9                        mysql-tools-8.4-lts-community               85 M

Transaction Summary
====================================================================================================================================
Install  3 Packages
Skip     1 Package

Total download size: 82 M
Installed size: 457 M
Downloading Packages:
(1/3): libssh-config-0.10.6-1.amzn2023.0.1.noarch.rpm                                               113 kB/s |  11 kB     00:00    
(2/3): libssh-0.10.6-1.amzn2023.0.1.x86_64.rpm                                                      2.0 MB/s | 217 kB     00:00    
(3/3): mysql-shell-8.4.4-1.el9.x86_64.rpm                                                            14 MB/s |  82 MB     00:05    
------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                14 MB/s |  82 MB     00:06     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                            1/1 
  Installing       : libssh-config-0.10.6-1.amzn2023.0.1.noarch                                                                 1/3 
  Installing       : libssh-0.10.6-1.amzn2023.0.1.x86_64                                                                        2/3 
  Installing       : mysql-shell-8.4.4-1.el9.x86_64                                                                             3/3 
  Running scriptlet: mysql-shell-8.4.4-1.el9.x86_64                                                                             3/3 
  Verifying        : libssh-0.10.6-1.amzn2023.0.1.x86_64                                                                        1/3 
  Verifying        : libssh-config-0.10.6-1.amzn2023.0.1.noarch                                                                 2/3 
  Verifying        : mysql-shell-8.4.4-1.el9.x86_64                                                                             3/3 
====================================================================================================================================
Installed:
  libssh-0.10.6-1.amzn2023.0.1.x86_64        libssh-config-0.10.6-1.amzn2023.0.1.noarch        mysql-shell-8.4.4-1.el9.x86_64       
Skipped:
  mysql-shell-8.4.6-1.el9.x86_64                                                                                                    

Complete!

$ mysqlsh --version
mysqlsh   Ver 8.4.4 for Linux on x86_64 - for MySQL 8.4.4 (MySQL Community Server (GPL))

Skipped となっていますが mysqlsh コマンドは反応するようになりました。

[蛇足] OPENSSL_3.2.0対応

mysqlsh コマンドは使えるっぽいものの、nothing provides libcrypto.so.3(OPENSSL_3.2.0)(64bit) が気になるので対応したいと思います。

OpenSSLのバージョンを確認するとたしかに古いのでAL2023のOSを更新します。リリースノートによれば 2023.7.20250331 から OpenSSL 3.2.2 に更新されているようです。

$ openssl version
OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)

ちなみに、AL2023のOSアップデートの方法は前に書いたので下記を参照ください。

↓↓ OSバージョンを 2023.7.20250623 にアップデートしました。

$ openssl version
OpenSSL 3.2.2 4 Jun 2024 (Library: OpenSSL 3.2.2 4 Jun 2024)

$ sudo dnf install -y mysql-shell
Package mysql-shell-8.4.6-1.el9.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

$ mysqlsh --version
mysqlsh   Ver 8.4.6 for Linux on x86_64 - for MySQL 8.4.6 (MySQL Community Server (GPL))

再度 dnf install mysql-shell してみましたが不要だった模様。OSアップデートだけすれば良さそうです。

これで mysqlsh コマンドがちゃんと(?)使えるようになりました!めでたしめでたし。

参考

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?