Ansibleを使用して他のサーバーにmysqlをインストールする手順について記載しています。
1.パッケージのダウンロード
次のコマンド輪実行します。
ansible TARGET_HOSTS -m yum -a "name=http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm" -u centos --sudo
実行結果
xxx.xxx.xxx.xxx | SUCCESS => {
"changed": true,
"msg": "",
"rc": 0,
"results": [ "Loaded plugins: fastestmirror\n
Examining /tmp/tmp7t8oxW/mysql57-community-release-el7-11.noarch.rpm: mysql57-community-release-el7-11.noarch\n
Marking /tmp/tmp7t8oxW/mysql57-community-release-el7-11.noarch.rpm to be installed\n
Resolving Dependencies\n
--> Running transaction check\n
---> Package mysql57-community-release.noarch 0:el7-11 will be installed\n
--> Finished Dependency Resolution\n
\n
Dependencies Resolved\n
\n
================================================================================\n
Package Arch Version\n
Repository Size\n
================================================================================\n
Installing:\n mysql57-community-release\n
noarch el7-11 /mysql57-community-release-el7-11.noarch 31 k\n
\n
Transaction Summary\n
================================================================================\n
Install 1 Package\n
\n
Total size: 31 k\n
Installed size: 31 k\n
Downloading packages:\n
Running transaction check\n
Running transaction test\n
Transaction test succeeded\n
Running transaction\n
Installing : mysql57-community-release-el7-11.noarch 1/1 \n
Verifying : mysql57-community-release-el7-11.noarch 1/1 \n
\n
Installed:\n
mysql57-community-release.noarch 0:el7-11 \n
\n
Complete!\n"
]
}
「Complete!」が表示されている事を確認します。
2.インストール
ansible TARGET_HOSTS -a "sudo yum -y install mysql"
実行結果
xxx.xxx.xxx.xxx | SUCCESS | rc=0 >>
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.19-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.19-1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.7.19-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-common(x86-64) >= 5.7.9 for package: mysql-community-libs-5.7.19-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-common.x86_64 0:5.7.19-1.el7 will be installed
---> Package mysql-community-libs-compat.x86_64 0:5.7.19-1.el7 will be obsoleting
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mysql-community-client x86_64 5.7.19-1.el7 mysql57-community 24 M
mysql-community-libs x86_64 5.7.19-1.el7 mysql57-community 2.1 M
replacing mariadb-libs.x86_64 1:5.5.52-1.el7
mysql-community-libs-compat x86_64 5.7.19-1.el7 mysql57-community 2.0 M
replacing mariadb-libs.x86_64 1:5.5.52-1.el7
Installing for dependencies:
mysql-community-common x86_64 5.7.19-1.el7 mysql57-community 272 k
Transaction Summary
================================================================================
Install 3 Packages (+1 Dependent package)
Total download size: 28 M
Downloading packages:
Public key for mysql-community-common-5.7.19-1.el7.x86_64.rpm is not installed
--------------------------------------------------------------------------------
Total 23 MB/s | 28 MB 00:01
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-common-5.7.19-1.el7.x86_64 1/5
Installing : mysql-community-libs-5.7.19-1.el7.x86_64 2/5
Installing : mysql-community-libs-compat-5.7.19-1.el7.x86_64 3/5
Installing : mysql-community-client-5.7.19-1.el7.x86_64 4/5
Erasing : 1:mariadb-libs-5.5.52-1.el7.x86_64 5/5
Verifying : mysql-community-libs-5.7.19-1.el7.x86_64 1/5
Verifying : mysql-community-common-5.7.19-1.el7.x86_64 2/5
Verifying : mysql-community-libs-compat-5.7.19-1.el7.x86_64 3/5
Verifying : mysql-community-client-5.7.19-1.el7.x86_64 4/5
Verifying : 1:mariadb-libs-5.5.52-1.el7.x86_64 5/5
Installed:
mysql-community-client.x86_64 0:5.7.19-1.el7
mysql-community-libs.x86_64 0:5.7.19-1.el7
mysql-community-libs-compat.x86_64 0:5.7.19-1.el7
Dependency Installed:
mysql-community-common.x86_64 0:5.7.19-1.el7
Replaced:
mariadb-libs.x86_64 1:5.5.52-1.el7
Complete!
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.19-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el7-11.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
3.バージョンの確認
次のコマンドを実行します。
ansible TARGET_HOSTS -a "mysql --version"
実行結果
xxx.xxx.xxx.xxx | SUCCESS | rc=0 >> mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper