![服务器崩溃,部分 MySQL 数据库损坏。尝试使用 InnoDB 恢复功能进行恢复,但 ibdata1 似乎已损坏](https://linux22.com/image/621560/%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%B4%A9%E6%BA%83%EF%BC%8C%E9%83%A8%E5%88%86%20MySQL%20%E6%95%B0%E6%8D%AE%E5%BA%93%E6%8D%9F%E5%9D%8F%E3%80%82%E5%B0%9D%E8%AF%95%E4%BD%BF%E7%94%A8%20InnoDB%20%E6%81%A2%E5%A4%8D%E5%8A%9F%E8%83%BD%E8%BF%9B%E8%A1%8C%E6%81%A2%E5%A4%8D%EF%BC%8C%E4%BD%86%20ibdata1%20%E4%BC%BC%E4%B9%8E%E5%B7%B2%E6%8D%9F%E5%9D%8F.png)
我遇到了一个问题。几天前,我的根服务器在一次断电后崩溃了。我意识到 MySQL 服务器无法启动。在日志中我发现 InnoDB 的 ibdata1 发生了错误。
我尝试了自动 InnoDB 恢复程序 (innodb_force_recovery)。我重新安装了 MySQL 服务器。所有这些方法都不起作用。我尝试了从论坛和其他社区平台获得的其他方法(my.cnf 中的其他变量等)。这些方法也没有帮助我。所以我认为我需要个人帮助。问题是我在互联网上找不到任何针对此问题的“真正”解决方案。
目前我的根目录上有一个 MariaDB 服务器(版本 5.5)。
我直接启动服务器(mysqld --console)时出现的错误消息是:
root@GPR0420:/var/lib# mysqld
131125 17:06:17 [Warning] An old style --language or -lc-message-dir value with language specific part detected: /usr/share/mysql/english/
131125 17:06:17 [Warning] Use --lc-messages-dir without language specific part instead.
131125 17:06:17 InnoDB: The InnoDB memory heap is disabled
131125 17:06:17 InnoDB: Mutexes and rw_locks use GCC atomic builtins
131125 17:06:17 InnoDB: Compressed tables use zlib 1.2.3.4
131125 17:06:17 InnoDB: Using Linux native AIO
131125 17:06:17 InnoDB: Initializing buffer pool, size = 128.0M
131125 17:06:17 InnoDB: Completed initialization of buffer pool
131125 17:06:17 InnoDB: highest supported file format is Barracuda.
InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on
InnoDB: Skipping log redo
InnoDB: Error: trying to access page number 4294899583 in space 0,
InnoDB: space name ./ibdata1,
InnoDB: which is outside the tablespace bounds.
InnoDB: Byte offset 0, len 16384, i/o type 10.
InnoDB: If you get this error at mysqld startup, please check that
InnoDB: your my.cnf matches the ibdata files that you have in the
InnoDB: MySQL server.
131125 17:06:17 InnoDB: Assertion failure in thread 140125885400864 in file fil0fil.c line 5451
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://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: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
131125 17:06:17 [ERROR] 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.
To report this bug, see http://kb.askmonty.org/en/reporting-bugs
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.
Server version: 5.5.34-MariaDB-1~squeeze
key_buffer_size=167772160
read_buffer_size=131072
max_used_connections=0
max_threads=153
thread_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 499482 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x0x0
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 = 0x0 thread_stack 0x30000
addr2line: 'mysqld': No such file
mysqld(my_print_stacktrace+0x2e)[0x7f719a2e621e]
mysqld(handle_fatal_signal+0x4ac)[0x7f7199ee641c]
/lib/libpthread.so.0(+0xeff0)[0x7f71995deff0]
/lib/libc.so.6(gsignal+0x35)[0x7f7197eb81b5]
/lib/libc.so.6(abort+0x180)[0x7f7197ebafc0]
mysqld(+0x8304e9)[0x7f719a23c4e9]
mysqld(+0x7ff71d)[0x7f719a20b71d]
mysqld(+0x80025f)[0x7f719a20c25f]
mysqld(+0x7ef407)[0x7f719a1fb407]
mysqld(+0x835422)[0x7f719a241422]
mysqld(+0x8380fc)[0x7f719a2440fc]
mysqld(+0x7ce0f2)[0x7f719a1da0f2]
mysqld(+0x802fe1)[0x7f719a20efe1]
mysqld(+0x80392c)[0x7f719a20f92c]
mysqld(+0x7a4af5)[0x7f719a1b0af5]
mysqld(+0x760e9e)[0x7f719a16ce9e]
mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x48)[0x7f7199ee8808]
mysqld(+0x38bd16)[0x7f7199d97d16]
mysqld(_Z11plugin_initPiPPci+0x785)[0x7f7199d9ad15]
mysqld(+0x2f3cb7)[0x7f7199cffcb7]
mysqld(_Z11mysqld_mainiPPc+0x5cd)[0x7f7199d00b7d]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7f7197ea4c8d]
mysqld(+0x2e90b5)[0x7f7199cf50b5]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
此错误表示 ibdata1 中存在错误或该文件已损坏。是否可以修复 ibdata1 文件?如果不能,我们可以从该文件中提取一些未损坏的数据吗?
我希望你能帮助我。很高兴能恢复“新”(不在任何备份中)数据,因为数据库包含统计信息。
谨致问候,Jonniboy
答案1
看起来您的 my.cnf 中的 innodb_force_recovery 设置为 6,因此它不会尝试基于二进制日志进行恢复,请尝试将其设置为 0。
http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
还请检查崩溃时是否激活了二进制日志: http://dev.mysql.com/doc/refman/5.5/en/binary-log.html