CentOS 7에 MySQL 5.6 설치(SCL)

CentOS 7에 MySQL 5.6 설치(SCL)

2022-10-05 last update

8 minutes reading MySQL scl centos7

소개



Software Collection (SCL)을 사용하여 CentOS7에 MySQL5.6 설치
상위 기사 : MySQL, MariaDB의 각종 설치 방법과 EOL 정리 - Qiita
참고 : Quick Start — Software Collections

지원



본 수법으로 도입한 경우, Red Hat Software Collections Product Life Cycle - Red Hat Customer Portal 보다, 2018-04가 EOL이라고 생각된다.
그 이후에 보고된 취약성이나 결함에 대한 대응은 실시되지 않을 가능성이 있다.

LOG



리포지토리 등록


# yum install -y centos-release-scl

설치


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

# yum install -y rh-mysql56
# scl enable rh-mysql56 bash
... 略

mysql 시작/정지


# systemctl start rh-mysql56-mysqld
# systemctl status rh-mysql56-mysqld
● rh-mysql56-mysqld.service - MySQL 5.6 database server
   Loaded: loaded (/usr/lib/systemd/system/rh-mysql56-mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-10-21 14:34:30 UTC; 2s ago
  Process: 580 ExecStartPost=/usr/bin/scl enable $RH_MYSQL56_SCLS_ENABLED -- /opt/rh/rh-mysql56/root/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 374 ExecStartPost=/usr/bin/scl enable $RH_MYSQL56_SCLS_ENABLED -- /opt/rh/rh-mysql56/root/usr/libexec/mysql-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 272 ExecStartPre=/usr/bin/scl enable $RH_MYSQL56_SCLS_ENABLED -- /opt/rh/rh-mysql56/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 246 ExecStartPre=/usr/bin/scl enable $RH_MYSQL56_SCLS_ENABLED -- /opt/rh/rh-mysql56/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
  Process: 240 ExecStartPre=/usr/bin/scl enable $RH_MYSQL56_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mysql56 (code=exited, status=0/SUCCESS)
 Main PID: 373 (mysqld_safe)
   CGroup: /docker/6bac11ce5afc7a46c22715a36c911135968027fb1d240ea678b59ac03a34e7fd/system.slice/rh-mysql56-mysqld.service
           tq373 /bin/sh /opt/rh/rh-mysql56/root/usr/bin/mysqld_safe --basedir=/opt/rh/rh-mysql56/root/usr
           mq548 /opt/rh/rh-mysql56/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mysql56/root/usr --datadir...
           ? 373 /bin/sh /opt/rh/rh-mysql56/root/usr/bin/mysqld_safe --basedir=/opt/rh/rh-mysql56/root/usr

Oct 21 14:34:27 6bac11ce5afc scl[272]: Note: new default config file not created.
Oct 21 14:34:27 6bac11ce5afc scl[272]: Please make sure your config file is current
Oct 21 14:34:27 6bac11ce5afc scl[272]: WARNING: Default config file /etc/opt/rh/rh-mysql56/my.cnf exis...ystem
Oct 21 14:34:27 6bac11ce5afc scl[272]: This file will be read by default by the MySQL server
Oct 21 14:34:27 6bac11ce5afc scl[272]: If you do not want to use this, either remove it, or use the
Oct 21 14:34:27 6bac11ce5afc scl[272]: --defaults-file argument to mysqld_safe when starting the server
Oct 21 14:34:27 6bac11ce5afc su[365]: (to mysql) root on none
Oct 21 14:34:28 6bac11ce5afc mysqld_safe-scl-helper[373]: 191021 14:34:28 mysqld_safe Logging to '/var/o...g'.
Oct 21 14:34:28 6bac11ce5afc mysqld_safe-scl-helper[373]: 191021 14:34:28 mysqld_safe Starting mysqld da...sql
Oct 21 14:34:30 6bac11ce5afc systemd[1]: Started MySQL 5.6 database server.
Hint: Some lines were ellipsized, use -l to show in full.
# systemctl stop rh-mysql56-mysqld
# systemctl status rh-mysql56-mysqld
● rh-mysql56-mysqld.service - MySQL 5.6 database server
   Loaded: loaded (/usr/lib/systemd/system/rh-mysql56-mysqld.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Oct 21 14:34:27 6bac11ce5afc scl[272]: WARNING: Default config file /etc/opt/rh/rh-mysql56/my.cnf exis...ystem
Oct 21 14:34:27 6bac11ce5afc scl[272]: This file will be read by default by the MySQL server
Oct 21 14:34:27 6bac11ce5afc scl[272]: If you do not want to use this, either remove it, or use the
Oct 21 14:34:27 6bac11ce5afc scl[272]: --defaults-file argument to mysqld_safe when starting the server
Oct 21 14:34:27 6bac11ce5afc su[365]: (to mysql) root on none
Oct 21 14:34:28 6bac11ce5afc mysqld_safe-scl-helper[373]: 191021 14:34:28 mysqld_safe Logging to '/var/o...g'.
Oct 21 14:34:28 6bac11ce5afc mysqld_safe-scl-helper[373]: 191021 14:34:28 mysqld_safe Starting mysqld da...sql
Oct 21 14:34:30 6bac11ce5afc systemd[1]: Started MySQL 5.6 database server.
Oct 21 14:35:01 6bac11ce5afc systemd[1]: Stopping MySQL 5.6 database server...
Oct 21 14:35:03 6bac11ce5afc systemd[1]: Stopped MySQL 5.6 database server.
Hint: Some lines were ellipsized, use -l to show in full.

mysql 자동 시작 설정 / 설정 해제


# systemctl enable rh-mysql56-mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-mysql56-mysqld.service to /usr/lib/systemd/system/rh-mysql56-mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
rh-mysql56-mysqld.service              enabled
# systemctl disable rh-mysql56-mysqld
Removed symlink /etc/systemd/system/multi-user.target.wants/rh-mysql56-mysqld.service.
# systemctl list-unit-files --type=service |grep mysql
rh-mysql56-mysqld.service              disabled

각종 확인


# systemctl start rh-mysql56-mysqld
# mysql -u root -e 'select version();'
+-----------+
| version() |
+-----------+
| 5.6.40    |
+-----------+