MariaDB 崩溃原因

MariaDB Crash Reason

我最近将一个小型数据仓库从 32 位 windows MySQL 5.5 实例迁移到一个更大的 MariaDB 实例。总体而言,性能改进符合预期。但是,我 运行 在数据库服务器重新启动的情况下无法确定导致崩溃的瓶颈。我在哪里可以看到导致崩溃的原因,以便我可以适当地调整配置文件?

设置为虚拟机如下:

下面是 journalctl -u mariadb --since "2018-11-26 14:00:00" 的输出,显示了恢复情况。 mariadb.service: main process exited 之前没有任何内容暗示 ~15:08:30 崩溃的原因。

Nov 26 15:09:19 NCSQL systemd[1]: mariadb.service: main process exited, code=killed, status=9/KILL
Nov 26 15:09:19 NCSQL systemd[1]: Unit mariadb.service entered failed state.
Nov 26 15:09:19 NCSQL systemd[1]: mariadb.service failed.
Nov 26 15:09:24 NCSQL systemd[1]: mariadb.service holdoff time over, scheduling restart.
Nov 26 15:09:24 NCSQL systemd[1]: Starting MariaDB 10.2.18 database server...
Nov 26 15:09:24 NCSQL systemd[1]: Starting MariaDB 10.2.18 database server...
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] /usr/sbin/mysqld (mysqld 10.2.18-MariaDB) starting as process 8873 ...
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Uses event mutexes
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Compressed tables use zlib 1.2.7
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Using Linux native AIO
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Number of pools: 1
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Using SSE2 crc32 instructions
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Initializing buffer pool, total size = 3G, instances = 8, chunk size = 128M
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Completed initialization of buffer pool
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140320821323520 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Highest supported file format is Barracuda.
Nov 26 15:09:25 NCSQL mysqld[8873]: 2018-11-26 15:09:25 140324770257088 [Note] InnoDB: Starting crash recovery from checkpoint LSN=277791212387
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] InnoDB: 128 out of 128 rollback segments are active.
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] InnoDB: Creating shared tablespace for temporary tables
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] InnoDB: Waiting for purge to start
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] InnoDB: 5.7.23 started; log sequence number 277791212441
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140320398370560 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] Plugin 'FEEDBACK' is disabled.
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] Recovering after a crash using tc.log
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] Starting crash recovery...
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] Crash recovery finished.
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140320398370560 [Note] InnoDB: Buffer pool(s) load completed at 181126 15:09:27
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] Server socket created on IP: '::'.
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [ERROR] mysqld: Table './mysql/event' is marked as crashed and should be repaired
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [ERROR] mysqld: Table 'event' is marked as crashed and should be repaired
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Warning] Checking table:   './mysql/event'
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [ERROR] mysql.event: 1 client is using or hasn't closed the table properly
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324635596544 [Note] Event Scheduler: scheduler thread started with id 6
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] Reading of all Master_info entries succeded
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] Added new Master_info '' to hash table
Nov 26 15:09:27 NCSQL mysqld[8873]: 2018-11-26 15:09:27 140324770257088 [Note] /usr/sbin/mysqld: ready for connections.
Nov 26 15:09:27 NCSQL mysqld[8873]: Version: '10.2.18-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
Nov 26 15:09:27 NCSQL systemd[1]: Started MariaDB 10.2.18 database server.

我的 server.cnf 有以下内容:

[mysqld]
lower_case_table_names=1
event_scheduler=on
max_heap_table_size=4G
key_buffer_size=20M
innodb_buffer_pool_size=3G
sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

您的 Table 似乎已损坏。 执行以下命令修复问题

REPAIR TABLE `<tableName>`; 

在你的情况下,

USE mysql
REPAIR TABLE event;

DB 服务正在被 Linux OOM 杀手关闭。因此,不会显示 MySQL/MariaDB 错误日志消息。

以下命令有助于确认:

# dmesg -T | egrep -i 'killed process'