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

# はじめに

Software Collection(SCL)を利用してCentOS7にMariaDB10.0をインストール
親記事：[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)より、2018-04が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-mariadb100
# scl enable rh-mariadb100 bash
... 略
```

### mysql起動/停止

```shell-session
# systemctl start rh-mariadb100-mariadb
# systemctl status rh-mariadb100-mariadb
● rh-mariadb100-mariadb.service - MariaDB 10.0 database server
   Loaded: loaded (/usr/lib/systemd/system/rh-mariadb100-mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-21 15:14:36 UTC; 10s ago
  Process: 555 ExecStartPost=/usr/bin/scl enable $RH_MARIADB100_SCLS_ENABLED -- /opt/rh/rh-mariadb100/root/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 403 ExecStartPost=/usr/bin/scl enable $RH_MARIADB100_SCLS_ENABLED -- /opt/rh/rh-mariadb100/root/usr/libexec/mysql-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 280 ExecStartPre=/usr/bin/scl enable $RH_MARIADB100_SCLS_ENABLED -- /opt/rh/rh-mariadb100/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 254 ExecStartPre=/usr/bin/scl enable $RH_MARIADB100_SCLS_ENABLED -- /opt/rh/rh-mariadb100/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
  Process: 248 ExecStartPre=/usr/bin/scl enable $RH_MARIADB100_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mariadb100 (code=exited, status=0/SUCCESS)
 Main PID: 402 (mysqld_safe)
   CGroup: /docker/f306e169a685c3f0ac252af7a0bbf377f3f7adf1bd16391e08d94bbea8fdb6bf/system.slice/rh-mariadb100-mariadb.service
           tq402 /bin/sh /opt/rh/rh-mariadb100/root/usr/bin/mysqld_safe --basedir=/opt/rh/rh-mariadb100/roo...
           mq525 /opt/rh/rh-mariadb100/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mariadb100/root/usr --d...
           ? 402 /bin/sh /opt/rh/rh-mariadb100/root/usr/bin/mysqld_safe --basedir=/opt/rh/rh-mariadb100/roo...

Oct 21 15:14:17 f306e169a685 systemd[1]: Starting MariaDB 10.0 database server...
Oct 21 15:14:21 f306e169a685 scl[280]: Initializing MariaDB database
Oct 21 15:14:21 f306e169a685 scl[280]: 191021 15:14:21 [Note] /opt/rh/rh-mariadb100/root/usr/libexec/m...8 ...
Oct 21 15:14:30 f306e169a685 scl[280]: 191021 15:14:30 [Note] /opt/rh/rh-mariadb100/root/usr/libexec/m...6 ...
Oct 21 15:14:33 f306e169a685 mysqld_safe-scl-helper[402]: 191021 15:14:33 mysqld_safe Logging to '/var/o...g'.
Oct 21 15:14:33 f306e169a685 mysqld_safe-scl-helper[402]: 191021 15:14:33 mysqld_safe Starting mysqld da...sql
Oct 21 15:14:36 f306e169a685 systemd[1]: Started MariaDB 10.0 database server.
Hint: Some lines were ellipsized, use -l to show in full.
```

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

Oct 21 15:14:17 f306e169a685 systemd[1]: Starting MariaDB 10.0 database server...
Oct 21 15:14:21 f306e169a685 scl[280]: Initializing MariaDB database
Oct 21 15:14:21 f306e169a685 scl[280]: 191021 15:14:21 [Note] /opt/rh/rh-mariadb100/root/usr/libexec/m...8 ...
Oct 21 15:14:30 f306e169a685 scl[280]: 191021 15:14:30 [Note] /opt/rh/rh-mariadb100/root/usr/libexec/m...6 ...
Oct 21 15:14:33 f306e169a685 mysqld_safe-scl-helper[402]: 191021 15:14:33 mysqld_safe Logging to '/var/o...g'.
Oct 21 15:14:33 f306e169a685 mysqld_safe-scl-helper[402]: 191021 15:14:33 mysqld_safe Starting mysqld da...sql
Oct 21 15:14:36 f306e169a685 systemd[1]: Started MariaDB 10.0 database server.
Oct 21 15:15:06 f306e169a685 systemd[1]: Stopping MariaDB 10.0 database server...
Oct 21 15:15:07 f306e169a685 systemd[1]: Stopped MariaDB 10.0 database server.
Hint: Some lines were ellipsized, use -l to show in full.
```

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

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

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

### 各種確認

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