客户数据库在运行过程中遇到突然断电,服务器重启后发现 MySQL 无法正常启动。查看错误日志后,报错信息如下:

151105 11:24:52 mysqld_safe Starting mysqld daemon with databases from /data/mysql/datafile
151105 11:24:52 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
151105 11:24:52 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
151105 11:24:52 InnoDB: The InnoDB memory heap is disabled
151105 11:24:52 InnoDB: Mutexes and rw_locks use GCC atomic builtins
151105 11:24:52 InnoDB: Compressed tables use zlib 1.2.3
151105 11:24:52 InnoDB: Initializing buffer pool, size = 512.0M
151105 11:24:52 InnoDB: Completed initialization of buffer pool
151105 11:24:52 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
151105 11:24:52 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
151105 11:24:52 InnoDB: ERROR: We were only able to scan the log up to
InnoDB: 2735615488, but a checkpoint was at 2735615806.
InnoDB: It is possible that the database is now corrupt!
InnoDB: 3 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 3 row operations to undo
InnoDB: Trx id counter is 6D84900
InnoDB: Last MySQL binlog file position 0 446116929, file name /data/mysql/binlog/mysql-bin.001288
InnoDB: Cleaning up trx with id 6D7C116
InnoDB: Cleaning up trx with id 6D74419
InnoDB: Cleaning up trx with id 6D6F27E
151105 11:24:52 InnoDB: Waiting for the background threads to start
151105 11:24:52 InnoDB: Assertion failure in thread 140108568532736 in file trx0purge.c line 848
InnoDB: Failing assertion: purge_sys->purge_trx_no <= purge_sys->rseg->last_trx_no
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to https://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: https://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
03:24:52 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we ha ve already crashed,
something is definitely wrong and this may fail.
Please help us make Percona Server better by reporting any
bugs at https://bugs.percona.com/
key_buffer_size=402653184
read_buffer_size=4194304
max_used_connections=0
max_threads=2002
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 16818378 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
/usr/local/percona-server-5.5.38-35.2/bin/mysqld(my_print_stacktrace+0x2e)[0x7785ae]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld(handle_fatal_signal+0x43a)[0x66a1da]
/lib64/libpthread.so.0[0x379c20f710]
/lib64/libc.so.6(gsignal+0x35)[0x379be32925]
/lib64/libc.so.6(abort+0x175)[0x379be34105]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x814fb0]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x8153f7]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x8e318f]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x8d98d5]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x813c4e]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x809d2c]
/lib64/libpthread.so.0[0x379c2079d1]
/lib64/libc.so.6(clone+0x6d)[0x379bee8b5d]
You may download the Percona Server operations manual by visiting
https://www.percona.com/software/percona-server/. You may find information
in the manual which will help you identify the cause of the crash.
151105 11:24:52 mysqld_safe mysqld from pid file /data/mysql/datafile/mysql.pid ended通过分析 MySQL 启动日志可以判断,数据库重启失败的主要原因是 ibdata1 文件损坏,导致 InnoDB 在异常断电后无法完成正常恢复。
此时通常需要跳过 InnoDB 自动恢复流程,修改 my.cnf 配置文件,并在 my.cnf 的 [mysqld] 段中添加以下参数:
innodb_force_recovery = 6
innodb_purge_threads = 0innodb_force_recovery 的取值范围为 1 到 6,数值越大,表示包含前面所有级别的恢复限制,常用于 MySQL 无法启动、InnoDB 表空间损坏、数据库异常断电后的紧急恢复场景。
1. (SRV_FORCE_IGNORE_CORRUPT):忽略检测到的损坏页。
2. (SRV_FORCE_NO_BACKGROUND):阻止主线程运行,如果主线程需要执行完整清理操作,可能会触发崩溃。
3. (SRV_FORCE_NO_TRX_UNDO):不执行事务回滚。
4. (SRV_FORCE_NO_IBUF_MERGE):不执行插入缓冲合并。
5. (SRV_FORCE_NO_UNDO_LOG_SCAN):不扫描 undo 日志,InnoDB 存储引擎会将未提交事务视为已提交。
6. (SRV_FORCE_NO_LOG_REDO):不执行 redo 前滚操作。
再次启动 MySQL,如果仍然无法启动,则可以尝试删除数据目录 datafile 下的 ibdata1、ib_logfile* 等相关文件。
数据库成功启动后,建议立即导出 MySQL 数据库并重新恢复,以完成 InnoDB 数据修复和业务数据重建。
