CentOS 7にMariaDB 10.1をインストール（SCL）

# はじめに

Software Collection(SCL)を利用してCentOS7にMariaDB10.1をインストール
親記事：[MySQL, MariaDBの各種インストール方法とEOLまとめ \- Qiita](https://qiita.com/witchcraze/items/72291ee035437ec83273)
参考：[Quick Start — Software Collections](https://www.softwarecollections.org/en/docs/)

## サポート

本手法で導入した場合、[Red Hat Software Collections Product Life Cycle - Red Hat Customer Portal](https://access.redhat.com/support/policy/updates/rhscl)より、2019-05がEOLだと思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

## LOG

### レポジトリ登録

```shell-session
# yum install -y centos-release-scl
```

### インストール

```shell-session
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

# yum install -y rh-mariadb101
# scl enable rh-mariadb101 bash
... 略
```

### mysql起動/停止

```shell-session
# systemctl start rh-mariadb101-mariadb
# systemctl status rh-mariadb101-mariadb
● rh-mariadb101-mariadb.service - MariaDB 10.1 database server
   Loaded: loaded (/usr/lib/systemd/system/rh-mariadb101-mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-21 15:21:59 UTC; 4s ago
  Process: 494 ExecStartPost=/usr/bin/scl enable $RH_MARIADB101_SCLS_ENABLED -- /opt/rh/rh-mariadb101/root/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 306 ExecStartPre=/usr/bin/scl enable $RH_MARIADB101_SCLS_ENABLED -- /opt/rh/rh-mariadb101/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 278 ExecStartPre=/usr/bin/scl enable $RH_MARIADB101_SCLS_ENABLED -- /opt/rh/rh-mariadb101/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
  Process: 272 ExecStartPre=/usr/bin/scl enable $RH_MARIADB101_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mariadb101 (code=exited, status=0/SUCCESS)
 Main PID: 464 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /docker/802c06c5702d9e569c4c1eb0b20a068b184a1ab109b753dfb395ce783c04bde2/system.slice/rh-mariadb101-mariadb.service
           mq464 /opt/rh/rh-mariadb101/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mariadb101/root/usr
           ? 464 /opt/rh/rh-mariadb101/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mariadb101/root/usr

Oct 21 15:21:44 802c06c5702d systemd[1]: Starting MariaDB 10.1 database server...
Oct 21 15:21:44 802c06c5702d scl[306]: Initializing MariaDB database
Oct 21 15:21:44 802c06c5702d scl[306]: 2019-10-21 15:21:44 140718561188032 [Note] /opt/rh/rh-mariadb10...6 ...
Oct 21 15:21:49 802c06c5702d scl[306]: 2019-10-21 15:21:49 140503643961536 [Note] /opt/rh/rh-mariadb10...6 ...
Oct 21 15:21:54 802c06c5702d scl[306]: 2019-10-21 15:21:54 140580316166336 [Note] /opt/rh/rh-mariadb10...6 ...
Oct 21 15:21:58 802c06c5702d scl[306]: PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
Oct 21 15:21:58 802c06c5702d scl[306]: To do so, start the server, then issue the following commands:
Oct 21 15:21:58 802c06c5702d mysqld_safe-scl-helper[464]: 2019-10-21 15:21:58 140591762720960 [Note] /op......
Oct 21 15:21:59 802c06c5702d systemd[1]: Started MariaDB 10.1 database server.
Hint: Some lines were ellipsized, use -l to show in full.
```

```shell-session
# systemctl stop rh-mariadb101-mariadb
# systemctl status rh-mariadb101-mariadb
● rh-mariadb101-mariadb.service - MariaDB 10.1 database server
   Loaded: loaded (/usr/lib/systemd/system/rh-mariadb101-mariadb.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Oct 21 15:21:44 802c06c5702d scl[306]: Initializing MariaDB database
Oct 21 15:21:44 802c06c5702d scl[306]: 2019-10-21 15:21:44 140718561188032 [Note] /opt/rh/rh-mariadb10...6 ...
Oct 21 15:21:49 802c06c5702d scl[306]: 2019-10-21 15:21:49 140503643961536 [Note] /opt/rh/rh-mariadb10...6 ...
Oct 21 15:21:54 802c06c5702d scl[306]: 2019-10-21 15:21:54 140580316166336 [Note] /opt/rh/rh-mariadb10...6 ...
Oct 21 15:21:58 802c06c5702d scl[306]: PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
Oct 21 15:21:58 802c06c5702d scl[306]: To do so, start the server, then issue the following commands:
Oct 21 15:21:58 802c06c5702d mysqld_safe-scl-helper[464]: 2019-10-21 15:21:58 140591762720960 [Note] /op......
Oct 21 15:21:59 802c06c5702d systemd[1]: Started MariaDB 10.1 database server.
Oct 21 15:22:29 802c06c5702d systemd[1]: Stopping MariaDB 10.1 database server...
Oct 21 15:22:31 802c06c5702d systemd[1]: Stopped MariaDB 10.1 database server.
Hint: Some lines were ellipsized, use -l to show in full.
```

### mysql自動起動設定/設定解除

```shell-session
# systemctl enable rh-mariadb101-mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-mariadb101-mariadb.service to /usr/lib/systemd/system/rh-mariadb101-mariadb.service.
# systemctl list-unit-files --type=service |grep maria
rh-mariadb101-mariadb.service          enabled
rh-mariadb101-mariadb@.service         disabled
```

```shell-session
# systemctl disable rh-mariadb101-mariadb
Removed symlink /etc/systemd/system/multi-user.target.wants/rh-mariadb101-mariadb.service.
# systemctl list-unit-files --type=service |grep maria
rh-mariadb101-mariadb.service          disabled
rh-mariadb101-mariadb@.service         disabled
```

### 各種確認

```shell-session
# systemctl start rh-mariadb101-mariadb
# mysql -u root -e 'select version();'
+-----------------+
| version()       |
+-----------------+
| 10.1.29-MariaDB |
+-----------------+
```