背景:
今天接到zabbix告警数据库宕机,手动ping无法ping通该服务器,联系负责服务器的同事查看,发现是由于自己误操作导致服务器关机了
问题:
服务器启动之后发现error.log有如下的报错
2025-03-12 2:37:05 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2025-03-12 2:37:05 0 [Note] InnoDB: Number of pools: 1
2025-03-12 2:37:05 0 [Note] InnoDB: Using generic crc32 instructions
2025-03-12 2:37:05 0 [Note] InnoDB: Initializing buffer pool, total size = 536870912, chunk size = 134217728
2025-03-12 2:37:05 0 [Note] InnoDB: Completed initialization of buffer pool
2025-03-12 2:37:05 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=203900693,203900693
2025-03-12 2:37:05 0 [Note] InnoDB: Starting final batch to recover 8 pages from redo log.
2025-03-12 2:37:05 0 [Note] InnoDB: Last binlog file './mysql-bin.000010', position 2465201
2025-03-12 2:37:05 0 [Note] InnoDB: 128 rollback segments are active.
2025-03-12 2:37:05 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
2025-03-12 2:37:05 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2025-03-12 2:37:05 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2025-03-12 2:37:05 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2025-03-12 2:37:05 0 [Note] InnoDB: 10.6.7 started; log sequence number 203969890; transaction id 13563717
2025-03-12 2:37:05 0 [Note] Plugin 'FEEDBACK' is disabled.
2025-03-12 2:37:05 0 [Note] InnoDB: Loading buffer pool(s) from /opt/zbox/data/mysql/ib_buffer_pool
2025-03-12 2:37:05 0 [Warning] 'innodb-log-files-in-group' was removed. It does nothing now and exists only for compatibility with old my.cnf files.
2025-03-12 2:37:05 0 [Note] Recovering after a crash using mysql-bin
2025-03-12 2:37:05 0 [Note] Starting table crash recovery...
2025-03-12 2:37:05 0 [Note] Crash table recovery finished.
2025-03-12 2:37:06 0 [Note] Server socket created on IP: '0.0.0.0'.
2025-03-12 2:37:06 0 [Note] /opt/zbox/run/mysql/mariadbd: ready for connections.
Version: '10.6.7-MariaDB-log' socket: '/opt/zbox/tmp/mysql/mysql.sock' port: 3306 Source distribution
2025-03-12 2:37:07 0 [Note] InnoDB: Buffer pool(s) load completed at 250312 2:37:07
2025-03-11 18:54:28 4 [Warning] IP address '10.0.53.40' could not be resolved: Name or service not known
2025-03-11 18:54:44 10 [ERROR] mariadbd: Table './zentao/zt_action' is marked as crashed and should be repaired
2025-03-11 18:54:44 10 [Warning] Checking table: './zentao/zt_action'
2025-03-11 18:54:45 10 [ERROR] mariadbd: Table './zentao/zt_history' is marked as crashed and should be repaired
2025-03-11 18:54:45 10 [Warning] Checking table: './zentao/zt_history'
2025-03-11 18:54:46 10 [ERROR] mariadbd: Table './zentao/zt_im_message' is marked as crashed and should be repaired
2025-03-11 18:54:46 10 [Warning] Checking table: './zentao/zt_im_message'
2025-03-11 18:54:48 10 [ERROR] mariadbd: Table './zentao/zt_im_messagestatus' is marked as crashed and should be repaired
2025-03-11 18:54:48 10 [Warning] Checking table: './zentao/zt_im_messagestatus'
2025-03-11 18:54:49 10 [ERROR] mariadbd: Table './zentao/zt_kanbancell' is marked as crashed and should be repaired
2025-03-11 18:54:49 10 [Warning] Checking table: './zentao/zt_kanbancell'
2025-03-11 18:54:49 10 [ERROR] mariadbd: Table './zentao/zt_kanbanlane' is marked as crashed and should be repaired
2025-03-11 18:54:49 10 [Warning] Checking table: './zentao/zt_kanbanlane'
2025-03-11 18:54:49 10 [ERROR] mariadbd: Table './zentao/zt_notify' is marked as crashed and should be repaired
2025-03-11 18:54:49 10 [Warning] Checking table: './zentao/zt_notify'
2025-03-11 18:54:49 10 [ERROR] mariadbd: Table './zentao/zt_user' is marked as crashed and should be repaired
2025-03-11 18:54:49 10 [Warning] Checking table: './zentao/zt_user'
2025-03-11 18:54:49 10 [ERROR] mariadbd: Table './zentao/zt_bug' is marked as crashed and should be repaired
2025-03-11 18:54:49 10 [Warning] Checking table: './zentao/zt_bug'
从日志信息来看,MariaDB 数据库中的 zentao 数据库下的某些表(zt_notify、zt_user 、zt_bug等表)被标记为已崩溃,并且需要修复
产生原因
1、服务器意外崩溃(如断电、强制关机)。
2、存储引擎(如 MyISAM)的固有缺陷(InnoDB 通常有自动崩溃恢复机制)。
3、磁盘故障或文件系统错误。
4、数据库进程异常终止。
repair table
使用repair table 对每个报错的表执行修复操作
MariaDB [(none)]> use zentao
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [zentao]> repair table zt_action;
+------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+------------------+--------+----------+----------+
| zentao.zt_action | repair | status | OK |
+------------------+--------+----------+----------+
1 row in set (25.300 sec)
MariaDB [zentao]> repair table zt_history;
+-------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+-------------------+--------+----------+----------+
| zentao.zt_history | repair | status | OK |
+-------------------+--------+----------+----------+
1 row in set (4.309 sec)
MariaDB [zentao]> repair table zt_im_message;
+----------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+----------------------+--------+----------+----------+
| zentao.zt_im_message | repair | status | OK |
+----------------------+--------+----------+----------+
1 row in set (7.188 sec)
MariaDB [zentao]> repair table zt_im_messagestatus;
+----------------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+----------------------------+--------+----------+----------+
| zentao.zt_im_messagestatus | repair | status | OK |
+----------------------------+--------+----------+----------+
1 row in set (0.474 sec)
MariaDB [zentao]> repair table zt_kanbancell;
+----------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+----------------------+--------+----------+----------+
| zentao.zt_kanbancell | repair | status | OK |
+----------------------+--------+----------+----------+
1 row in set (0.047 sec)
MariaDB [zentao]> repair table zt_kanbanlane;
+----------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+----------------------+--------+----------+----------+
| zentao.zt_kanbanlane | repair | status | OK |
+----------------------+--------+----------+----------+
1 row in set (0.004 sec)
MariaDB [zentao]> repair table zt_notify;
+------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+------------------+--------+----------+----------+
| zentao.zt_notify | repair | status | OK |
+------------------+--------+----------+----------+
1 row in set (3.196 sec)
MariaDB [zentao]> repair table zt_user;
+----------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+----------------+--------+----------+----------+
| zentao.zt_user | repair | status | OK |
+----------------+--------+----------+----------+
1 row in set (0.082 sec)
MariaDB [zentao]> repair table zt_bug;
+---------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+---------------+--------+----------+----------+
| zentao.zt_bug | repair | status | OK |
+---------------+--------+----------+----------+
1 row in set (2.366 sec)
检查表状态
检查一下修复后表的状态,部分展示一下这些表
+------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+------------------+--------+----------+----------+
| zentao.zt_user | check | status | OK |
+------------------+--------+----------+----------+
+------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+------------------+--------+----------+----------+
| zentao.zt_user | check | status | OK |
+------------------+--------+----------+----------+
注意:
MyISAM 表:更易损坏,需定期维护。
InnoDB 表:通常能自动恢复,若手动修复失败,需从备份恢复或使用 innodb_force_recovery 模式。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




