Mariadb 实例无法启动,有哪些故障排除步骤?

Mariadb 实例无法启动,有哪些故障排除步骤?

一个已存在多年且多年来经历了多次升级的现有 mariadb 实例将无法再启动。在 Linux Mint 上运行我刚刚注意到它已关闭,但不确定问题何时开始。

    systemctl status mariadb.service
    mariadb.service - MariaDB 10.1.48 database server
      Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
      Active: failed (Result: exit-code) since Tue 2023-02-14 16:22:28 EST; 1h 25min ago
        Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
    Process: 4815 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
    Process: 4741 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCES
    Process: 4739 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 4738 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 4815 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

Feb 14 16:22:24 LM18-Virtual-Machine systemd[1]: Starting MariaDB 10.1.48 database server...
Feb 14 16:22:25 LM18-Virtual-Machine mysqld[4815]: 2023-02-14 16:22:25 3078166144 [Note] /usr/sbin/mysqld (mysqld 10.1.48-MariaDB-0ubuntu0.18.04.1) starting as process 4815 ...
Feb 14 16:22:28 LM18-Virtual-Machine systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 14 16:22:28 LM18-Virtual-Machine systemd[1]: mariadb.service: Failed with result 'exit-code'.
Feb 14 16:22:28 LM18-Virtual-Machine systemd[1]: Failed to start MariaDB 10.1.48 database server.

分区上有足够的磁盘空间。其中一个表有 15GB,但远低于最大大小。

机器上有大量可用内存。

以下是尝试启动服务失败后 journalctl -xe 的结果。

-- Unit mariadb.service has begun starting up.
Feb 14 18:05:44 LM18-Virtual-Machine mysqld[5884]: 2023-02-14 18:05:44 3078329984 [Note] /usr/sbin/mysqld (mysqld 10.1.48-MariaDB-0ubuntu0.18.04.1) starting as process 5884 ...
Feb 14 18:05:47 LM18-Virtual-Machine systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 14 18:05:47 LM18-Virtual-Machine systemd[1]: mariadb.service: Failed with result 'exit-code'.
Feb 14 18:05:47 LM18-Virtual-Machine systemd[1]: Failed to start MariaDB 10.1.48 database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mariadb.service has failed.
--
-- The result is RESULT.

结果是 RESULT 是一个非常有用的错误代码。

我接下来应该看什么来确定问题?

答案1

我接下来要做的是查看错误日志(更多信息)。这可能位于 /var/log/mysql/error.log 或 /var/log/mysql/mariadb.err 可能未设置(您需要设置它)。要知道它在哪里(假设您无法运行查询,因为您无法启动数据库),您可以执行以下操作:

find /etc/mysql -type f -exec grep log_error {} \;

在我的服务器上它看起来像这样:

# find /etc/mysql -type f -exec grep log_error {} \;
log_error = /var/log/mysql/error.log
skip_log_error

所以我知道它在 /var/log/mysql/error.log 上

如果此错误日志不够明确,我接下来要做的就是使用 mysqld_safe 或 mariadbd-safe 启动数据库(更多信息在我的服务器上它看起来像这样:

# mysqld_safe
230215 09:23:28 mysqld_safe Logging to syslog.
230215 09:23:28 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql

如果我检查系统日志:

# grep mysqld /var/log/syslog
Feb 15 09:23:28 birch mysqld_safe: Starting mariadbd daemon with databases from /var/lib/mysql
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] /usr/sbin/mariadbd (mysqld 10.5.12-MariaDB-0+deb11u1-log) starting as process 2035918 ...
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Uses event mutexes
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Number of pools: 1
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Using Linux native AIO
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Completed initialization of buffer pool
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: 128 rollback segments are active.
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Creating shared tablespace for temporary tables
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: 10.5.12 started; log sequence number 134979417; transaction id 120284
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] Plugin 'FEEDBACK' is disabled.
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] Server socket created on IP: '0.0.0.0'.
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] Reading of all Master_info entries succeeded
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] Added new Master_info '' to hash table
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] /usr/sbin/mariadbd: ready for connections.
Feb 15 09:23:28 birch mysqld: Version: '10.5.12-MariaDB-0+deb11u1-log'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Debian 11
Feb 15 09:23:28 birch mysqld: 2023-02-15  9:23:28 0 [Note] InnoDB: Buffer pool(s) load completed at 230215  9:23:28
Feb 15 09:24:20 birch mysqld: 2023-02-15  9:24:20 4 [Note] Start binlog_dump to slave_server(3), pos(mysql-bin.000006, 342), using_gtid(0), gtid('')

要停止 mysqld_safe,您需要运行:

# mysqladmin -p shutdown
Enter password:

相关内容