故障现象:无法正常启动
[root@VM_0_3_centos ~]# systemctl start mariadb
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
根据提示执行systemctl status mariadb.service,无明确指向
[root@VM_0_3_centos ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2020-05-14 09:35:00 CST; 1min 42s ago
Process: 12544 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
Process: 12543 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
Process: 12509 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 12543 (code=exited, status=0/SUCCESS)
May 14 09:34:59 VM_0_3_centos systemd[1]: Starting MariaDB database server...
May 14 09:34:59 VM_0_3_centos mariadb-prepare-db-dir[12509]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
May 14 09:34:59 VM_0_3_centos mysqld_safe[12543]: 200514 09:34:59 mysqld_safe Logging to '/var/lib/mysql/VM_0_3_centos.err'.
May 14 09:34:59 VM_0_3_centos mysqld_safe[12543]: 200514 09:34:59 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
May 14 09:35:00 VM_0_3_centos systemd[1]: mariadb.service: control process exited, code=exited status=1
May 14 09:35:00 VM_0_3_centos systemd[1]: Failed to start MariaDB database server.
May 14 09:35:00 VM_0_3_centos systemd[1]: Unit mariadb.service entered failed state.
May 14 09:35:00 VM_0_3_centos systemd[1]: mariadb.service failed.
根据提示执行journalctl -xe,无明确指向
[root@VM_0_3_centos ~]# journalctl -xe
May 14 09:34:57 VM_0_3_centos polkitd[629]: Registered Authentication Agent for unix-process:12489:329075 (system bus name :1.154 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/Authe
May 14 09:34:57 VM_0_3_centos polkitd[629]: Unregistered Authentication Agent for unix-process:12489:329075 (system bus name :1.154, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.utf8) (disconnec
May 14 09:34:59 VM_0_3_centos polkitd[629]: Registered Authentication Agent for unix-process:12503:329280 (system bus name :1.155 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/Authe
May 14 09:34:59 VM_0_3_centos systemd[1]: Cannot add dependency job for unit rpcbind.socket, ignoring: Unit not found.
May 14 09:34:59 VM_0_3_centos systemd[1]: Starting MariaDB database server...
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has begun starting up.
May 14 09:34:59 VM_0_3_centos mariadb-prepare-db-dir[12509]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
May 14 09:34:59 VM_0_3_centos mariadb-prepare-db-dir[12509]: If this is not the case, make sure the /var/lib/mysql is empty before running mariadb-prepare-db-dir.
May 14 09:34:59 VM_0_3_centos mysqld_safe[12543]: 200514 09:34:59 mysqld_safe Logging to '/var/lib/mysql/VM_0_3_centos.err'.
May 14 09:34:59 VM_0_3_centos mysqld_safe[12543]: 200514 09:34:59 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
May 14 09:35:00 VM_0_3_centos systemd[1]: mariadb.service: control process exited, code=exited status=1
May 14 09:35:00 VM_0_3_centos systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has failed.
--
-- The result is failed.
May 14 09:35:00 VM_0_3_centos systemd[1]: Unit mariadb.service entered failed state.
May 14 09:35:00 VM_0_3_centos systemd[1]: mariadb.service failed.
May 14 09:35:00 VM_0_3_centos polkitd[629]: Unregistered Authentication Agent for unix-process:12503:329280 (system bus name :1.155, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.utf8) (disconnec
May 14 09:35:01 VM_0_3_centos systemd[1]: Started Session 59 of user root.
-- Subject: Unit session-59.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-59.scope has finished starting up.
--
-- The start-up result is done.
May 14 09:35:01 VM_0_3_centos CROND[12856]: (root) CMD (flock -xn /tmp/stargate.lock -c '/usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &')
May 14 09:36:01 VM_0_3_centos systemd[1]: Started Session 60 of user root.
-- Subject: Unit session-60.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-60.scope has finished starting up.
--
-- The start-up result is done.
May 14 09:36:01 VM_0_3_centos CROND[13031]: (root) CMD (flock -xn /tmp/stargate.lock -c '/usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &')
[5]+ Stopped journalctl -xe
进一步查看日志/var/lib/mysql/VM_0_3_centos.err
[root@VM_0_3_centos ~]# tail -f /var/lib/mysql/VM_0_3_centos.err
In case (b) you need to set innodb_log_file_size = 48M
200514 9:39:58 [ERROR] Plugin 'InnoDB' init function returned error.
200514 9:39:58 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
200514 9:39:58 [Note] Plugin 'FEEDBACK' is disabled.
200514 9:39:58 [ERROR] Unknown/unsupported storage engine: InnoDB
200514 9:39:58 [ERROR] Aborting
200514 9:39:58 [Note] /usr/libexec/mysqld: Shutdown complete
200514 09:39:58 mysqld_safe mysqld from pid file /var/lib/mysql/VM_0_3_centos.pid ended
200514 09:46:05 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
200514 9:46:05 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
200514 9:46:05 [Note] /usr/libexec/mysqld (mysqld 5.5.65-MariaDB) starting as process 15530 ...
200514 9:46:05 InnoDB: The InnoDB memory heap is disabled
200514 9:46:05 InnoDB: Mutexes and rw_locks use GCC atomic builtins
200514 9:46:05 InnoDB: Compressed tables use zlib 1.2.7
200514 9:46:05 InnoDB: Using Linux native AIO
200514 9:46:05 InnoDB: Initializing buffer pool, size = 128.0M
200514 9:46:05 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
InnoDB: Possible causes for this error:
(a) Incorrect log file is used or log file size is changed
(b) In case default size is used this log file is from 10.0
(c) Log file is corrupted or there was not enough disk space
In case (b) you need to set innodb_log_file_size = 48M
200514 9:46:05 [ERROR] Plugin 'InnoDB' init function returned error.
200514 9:46:05 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
200514 9:46:05 [Note] Plugin 'FEEDBACK' is disabled.
200514 9:46:05 [ERROR] Unknown/unsupported storage engine: InnoDB
200514 9:46:05 [ERROR] Aborting
200514 9:46:05 [Note] /usr/libexec/mysqld: Shutdown complete
200514 09:46:05 mysqld_safe mysqld from pid file /var/lib/mysql/VM_0_3_centos.pid ended
^Z
[1]+ Stopped tail -f /var/lib/mysql/VM_0_3_centos.err
高度怀疑ib_logfile0问题,执行如下操作后故障消除
cd /var/lib/mysql
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak
执行systemctl start mariadb.service正常
注:此类故障网上大量的资料是如下处置(本例中无效)
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
个人总结关键还是要细看mysql日志