2019년 5월 29일 수요일

[Linux] MariaDB가 구동되지 않을 경우

서비스 상태를 확인

# systemctl status mariadb.service
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor pres                                                                                                                                   et: disabled)
   Active: failed (Result: exit-code) since Mon 2019-05-27 18:04:14 KST; 1 day 2                                                                                                                                   3h ago
  Process: 18205 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=ex                                                                                                                                   ited, status=1/FAILURE)
  Process: 18204 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, sta                                                                                                                                   tus=0/SUCCESS)
  Process: 18171 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exite                                                                                                                                   d, status=0/SUCCESS)
 Main PID: 18204 (code=exited, status=0/SUCCESS)

May 27 18:04:12 ns1.qnct.cn systemd[1]: Starting MariaDB database server...
May 27 18:04:12 ns1.qnct.cn mariadb-prepare-db-dir[18171]: Database MariaDB i...
May 27 18:04:12 ns1.qnct.cn mariadb-prepare-db-dir[18171]: If this is not the...
May 27 18:04:12 ns1.qnct.cn mysqld_safe[18204]: 190527 18:04:12 mysqld_safe ....
May 27 18:04:12 ns1.qnct.cn mysqld_safe[18204]: 190527 18:04:12 mysqld_safe ...l
May 27 18:04:14 ns1.qnct.cn systemd[1]: mariadb.service: control process exi...1
May 27 18:04:14 ns1.qnct.cn systemd[1]: Failed to start MariaDB database server.
May 27 18:04:14 ns1.qnct.cn systemd[1]: Unit mariadb.service entered failed ....
May 27 18:04:14 ns1.qnct.cn systemd[1]: mariadb.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

해결책
/var/lib/mysql 폴더의 아래 3개 파일을 삭제 후 서비스 시작한다.
-rw-rw---- 1 mysql mysql 18874368 May 29 17:28 ibdata1
-rw-rw---- 1 mysql mysql  5242880 May 29 17:28 ib_logfile0
-rw-rw---- 1 mysql mysql  5242880 May 29 17:28 ib_logfile1





# systemctl status mariadb.service
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-05-29 17:28:31 KST; 14s ago
  Process: 22925 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 22891 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 22924 (mysqld_safe)
    Tasks: 21
   CGroup: /system.slice/mariadb.service
           ├─22924 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─23243 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/lib/mysql/ns1.qnct.cn.err --pid-file=ns1.qnct.cn.pid --port=3306

May 29 17:28:27 ns1.qnct.cn systemd[1]: Starting MariaDB database server...
May 29 17:28:27 ns1.qnct.cn mariadb-prepare-db-dir[22891]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
May 29 17:28:27 ns1.qnct.cn mariadb-prepare-db-dir[22891]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
May 29 17:28:27 ns1.qnct.cn mysqld_safe[22924]: 190529 17:28:27 mysqld_safe Logging to '/var/lib/mysql/ns1.qnct.cn.err'.
May 29 17:28:27 ns1.qnct.cn mysqld_safe[22924]: 190529 17:28:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
May 29 17:28:31 ns1.qnct.cn systemd[1]: Started MariaDB database server.