ブラックボックス

プログラミングのノウハウやライフハックをどんどん投稿していきたい

Mar 18, 2018 - 2 minute read - ノウハウ

【Docker】Amazon Linux2にMySQL5.7をインストールする

デフォルトだとMariaDBがインストールされるとのことなので、MySQLのインストール方法を見てみる。
環境:

  • Ubuntu 16.04(Vagrant ゲストOS)
  • Docker 17.09.1-ce
  • Amazon Linux 2.0(2017.12)

環境の詳細は下記

$ cat /etc/image-id
image_name="amzn2-container-raw"
image_version="2017.12"
image_arch="x86_64"
image_stamp="bccc-5374"
image_date="20180223004447"
recipe_name="amzn2 container"
recipe_id="d21f056b-cf17-aecd-ff56-0cd9-b6b0-1928-81c28b2b"

まずは何も考えずにyumでインストールしてみる。

$ yum install mysql
:
:
================================================================================
 Package                   Arch      Version                Repository     Size
================================================================================
Installing:
 mariadb                   x86_64    1:5.5.56-2.amzn2       amzn2-core    8.9 M
Installing for dependencies:
 groff-base                x86_64    1.22.2-8.amzn2         amzn2-core    946 k
 mariadb-libs              x86_64    1:5.5.56-2.amzn2       amzn2-core    768 k
 perl                      x86_64    4:5.16.3-292.amzn2     amzn2-core    8.0 M
 perl-Carp                 noarch    1.26-244.amzn2         amzn2-core     19 k
 perl-Encode               x86_64    2.51-7.amzn2           amzn2-core    1.5 M
 perl-Exporter             noarch    5.68-3.amzn2           amzn2-core     29 k
 perl-File-Path            noarch    2.09-2.amzn2           amzn2-core     27 k
 perl-File-Temp            noarch    0.23.01-3.amzn2        amzn2-core     56 k
 perl-Filter               x86_64    1.49-3.amzn2           amzn2-core     76 k
 perl-Getopt-Long          noarch    2.40-2.amzn2           amzn2-core     56 k
 perl-HTTP-Tiny            noarch    0.033-3.amzn2          amzn2-core     38 k
 perl-PathTools            x86_64    3.40-5.amzn2           amzn2-core     83 k
 perl-Pod-Escapes          noarch    1:1.04-292.amzn2       amzn2-core     51 k
 perl-Pod-Perldoc          noarch    3.20-4.amzn2           amzn2-core     87 k
 perl-Pod-Simple           noarch    1:3.28-4.amzn2         amzn2-core    216 k
 perl-Pod-Usage            noarch    1.63-3.amzn2           amzn2-core     27 k
 perl-Scalar-List-Utils    x86_64    1.27-248.amzn2         amzn2-core     36 k
 perl-Socket               x86_64    2.010-4.amzn2          amzn2-core     49 k
 perl-Storable             x86_64    2.45-3.amzn2           amzn2-core     78 k
 perl-Text-ParseWords      noarch    3.29-4.amzn2           amzn2-core     14 k
 perl-Time-HiRes           x86_64    4:1.9725-3.amzn2       amzn2-core     45 k
 perl-Time-Local           noarch    1.2300-2.amzn2         amzn2-core     24 k
 perl-constant             noarch    1.27-2.amzn2           amzn2-core     19 k
 perl-libs                 x86_64    4:5.16.3-292.amzn2     amzn2-core    700 k
 perl-macros               x86_64    4:5.16.3-292.amzn2     amzn2-core     43 k
 perl-parent               noarch    1:0.225-244.amzn2      amzn2-core     12 k
 perl-podlators            noarch    2.5.1-3.amzn2          amzn2-core    112 k
 perl-threads              x86_64    1.87-4.amzn2           amzn2-core     50 k
 perl-threads-shared       x86_64    1.43-6.amzn2           amzn2-core     39 k

Transaction Summary
================================================================================
Install  1 Package (+29 Dependent packages)

Total download size: 22 M
Installed size: 93 M
Is this ok [y/d/N]:

確かにMariaDBとなっている。

そこでMySQLのリポジトリを入れてインストールをしてみる。

$ yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Loaded plugins: ovl, priorities
mysql57-community-release-el7-11.noarch.rpm              |  25 kB     00:00
Examining /var/tmp/yum-root-NMLmdF/mysql57-community-release-el7-11.noarch.rpm: mysql57-community-release-el7-11.noarch
Marking /var/tmp/yum-root-NMLmdF/mysql57-community-release-el7-11.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch   Version
                                 Repository                                Size
================================================================================
Installing:
 mysql57-community-release
                   noarch el7-11 /mysql57-community-release-el7-11.noarch  31 k

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

Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql57-community-release-el7-11.noarch                      1/1
  Verifying  : mysql57-community-release-el7-11.noarch                      1/1

Installed:
  mysql57-community-release.noarch 0:el7-11

Complete!

リポジトリの追加は。
次にMySQLのインストール。

$ yum install mysql-community-server
:
:
================================================================================
 Package                Arch   Version                  Repository         Size
================================================================================
Installing:
 mysql-community-server x86_64 5.7.21-1.el7             mysql57-community 164 M
Installing for dependencies:
 groff-base             x86_64 1.22.2-8.amzn2           amzn2-core        946 k
 libaio                 x86_64 0.3.109-13.amzn2         amzn2-core         24 k
 mysql-community-client x86_64 5.7.21-1.el7             mysql57-community  24 M
 mysql-community-common x86_64 5.7.21-1.el7             mysql57-community 272 k
 mysql-community-libs   x86_64 5.7.21-1.el7             mysql57-community 2.1 M
 net-tools              x86_64 2.0-0.22.20131004git.amzn2
                                                        amzn2-core        303 k
 numactl-libs           x86_64 2.0.9-6.amzn2            amzn2-core         29 k
 perl                   x86_64 4:5.16.3-292.amzn2       amzn2-core        8.0 M
 perl-Carp              noarch 1.26-244.amzn2           amzn2-core         19 k
 perl-Encode            x86_64 2.51-7.amzn2             amzn2-core        1.5 M
 perl-Exporter          noarch 5.68-3.amzn2             amzn2-core         29 k
 perl-File-Path         noarch 2.09-2.amzn2             amzn2-core         27 k
 perl-File-Temp         noarch 0.23.01-3.amzn2          amzn2-core         56 k
 perl-Filter            x86_64 1.49-3.amzn2             amzn2-core         76 k
 perl-Getopt-Long       noarch 2.40-2.amzn2             amzn2-core         56 k
 perl-HTTP-Tiny         noarch 0.033-3.amzn2            amzn2-core         38 k
 perl-PathTools         x86_64 3.40-5.amzn2             amzn2-core         83 k
 perl-Pod-Escapes       noarch 1:1.04-292.amzn2         amzn2-core         51 k
 perl-Pod-Perldoc       noarch 3.20-4.amzn2             amzn2-core         87 k
 perl-Pod-Simple        noarch 1:3.28-4.amzn2           amzn2-core        216 k
 perl-Pod-Usage         noarch 1.63-3.amzn2             amzn2-core         27 k
 perl-Scalar-List-Utils x86_64 1.27-248.amzn2           amzn2-core         36 k
 perl-Socket            x86_64 2.010-4.amzn2            amzn2-core         49 k
 perl-Storable          x86_64 2.45-3.amzn2             amzn2-core         78 k
 perl-Text-ParseWords   noarch 3.29-4.amzn2             amzn2-core         14 k
 perl-Time-HiRes        x86_64 4:1.9725-3.amzn2         amzn2-core         45 k
 perl-Time-Local        noarch 1.2300-2.amzn2           amzn2-core         24 k
 perl-constant          noarch 1.27-2.amzn2             amzn2-core         19 k
 perl-libs              x86_64 4:5.16.3-292.amzn2       amzn2-core        700 k
 perl-macros            x86_64 4:5.16.3-292.amzn2       amzn2-core         43 k
 perl-parent            noarch 1:0.225-244.amzn2        amzn2-core         12 k
 perl-podlators         noarch 2.5.1-3.amzn2            amzn2-core        112 k
 perl-threads           x86_64 1.87-4.amzn2             amzn2-core         50 k
 perl-threads-shared    x86_64 1.43-6.amzn2             amzn2-core         39 k
 procps-ng              x86_64 3.3.10-16.amzn2          amzn2-core        291 k

Transaction Summary
================================================================================
Install  1 Package (+35 Dependent packages)

Total download size: 203 M
Installed size: 899 M
Is this ok [y/d/N]:

これでMySQL5.7がインストール出来る。
念の為バージョンを確認。

$ mysqld --version
mysqld  Ver 5.7.21 for Linux on x86_64 (MySQL Community Server (GPL))

問題なくインストールが出来た。