mysql表文件或者数据损坏
侧边栏壁纸
博主昵称
yuc

  • 累计撰写 291 篇文章
  • 累计收到 0 条评论

mysql表文件或者数据损坏

yuc
yuc
2024-05-07 / 最后修改: 2024-05-07 06:30 / 0 评论 / 5 阅读 / 正在检测是否收录...
异常问题

mysql运行异常、宕机,日志如下:

InnoDB: End of page dump
2019-05-26T05:44:41.901012Z 44 [Note] InnoDB: Uncompressed page, stored checksum in field1 851205953, calculated checksums for field1: crc32 4086194213/29424421, innodb 2478445248, none 3735928559, stored checksum in field2 1958202064, calculated checksums for field2: crc32 4086194213/29424421, innodb 4236257487, none 3735928559,  page LSN 61 1536263792, low 4 bytes of LSN at page end 2321078681, page number (if stored to page already) 1, space id (if created with >= MySQL-4.1.1 and stored already) 181012
InnoDB: Page may be an insert buffer bitmap page
2019-05-26T05:44:41.901034Z 44 [Note] InnoDB: It is also possible that your operating system has corrupted its own file cache and rebooting your computer removes the error. If the corrupt page is an index page. You can also try to fix the corruption by dumping, dropping, and reimporting the corrupt table. You can use CHECK TABLE to scan your table for corruption. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.
2019-05-26T05:44:41.901047Z 44 [ERROR] [FATAL] InnoDB: Unable to read page [page id: space=181012, page number=1] into the buffer pool after 100 attempts. The most probable cause of this error may be that the table has been corrupted. Or, the table was compressed with with an algorithm that is not supported by this instance. If it is not a decompress failure, you can try to fix this problem by using innodb_force_recovery. Please see http://dev.mysql.com/doc/refman/5.7/en/ for more details. Aborting...
2019-05-26 13:44:41 0x7f5053596700  InnoDB: Assertion failure in thread 139982972479232 in file ut0ut.cc line 942
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.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
05:44:41 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.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=268435456
read_buffer_size=2097152
max_used_connections=71
max_threads=1024
thread_count=71
connection_count=71
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 4470152 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7f4f58000ae0
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 = 7f5053595e28 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x35)[0xf54535]
/usr/sbin/mysqld(handle_fatal_signal+0x4a4)[0x7d3b54]
/lib64/libpthread.so.0(+0xf7e0)[0x7f5618fce7e0]
/lib64/libc.so.6(gsignal+0x35)[0x7f5617a6e4f5]
/lib64/libc.so.6(abort+0x175)[0x7f5617a6fcd5]
/usr/sbin/mysqld(_Z18ut_print_timestampP8_IO_FILE+0x0)[0x7c2c78]
/usr/sbin/mysqld(_ZN2ib5fatalD1Ev+0xb3)[0x10f4cc3]
/usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x1606)[0x11363d6]
/usr/sbin/mysqld[0xfc4a87]
/usr/sbin/mysqld(_Z29ibuf_merge_or_delete_for_pageP11buf_block_tRK9page_id_tPK11page_size_tm+0x7dd)[0xfcbedd]
/usr/sbin/mysqld(_Z20buf_page_io_completeP10buf_page_tb+0x4c9)[0x1130619]
/usr/sbin/mysqld[0x11534fc]
/usr/sbin/mysqld(_Z13buf_read_pageRK9page_id_tRK11page_size_t+0x40)[0x1153c80]
/usr/sbin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0xd21)[0x1135af1]
/usr/sbin/mysqld(_Z18btr_root_block_getPK12dict_index_tmP5mtr_t+0xd8)[0x10fd0e8]
/usr/sbin/mysqld(_Z12btr_root_getPK12dict_index_tP5mtr_t+0x11)[0x10fd201]
/usr/sbin/mysqld(_Z18btr_validate_indexP12dict_index_tPK5trx_tb+0x1a4)[0x110a264]
/usr/sbin/mysqld(_ZN11ha_innobase5checkEP3THDP15st_ha_check_opt+0x19a)[0xf8bc7a]
/usr/sbin/mysqld(_ZN7handler8ha_checkEP3THDP15st_ha_check_opt+0x79)[0x824089]
/usr/sbin/mysqld[0xe8c3b3]
/usr/sbin/mysqld(_ZN19Sql_cmd_check_table7executeEP3THD+0xcf)[0xe8ceef]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THDb+0xdb9)[0xd137a9]
/usr/sbin/mysqld(_Z11mysql_parseP3THDP12Parser_state+0x40d)[0xd17e1d]
/usr/sbin/mysqld(_Z16dispatch_commandP3THDPK8COM_DATA19enum_server_command+0x174e)[0xd195ee]
/usr/sbin/mysqld(_Z10do_commandP3THD+0x194)[0xd19f54]
/usr/sbin/mysqld(handle_connection+0x2b4)[0xdef2c4]
/usr/sbin/mysqld(pfs_spawn_thread+0x174)[0x126ac94]
/lib64/libpthread.so.0(+0x7aa1)[0x7f5618fc6aa1]
/lib64/libc.so.6(clone+0x6d)[0x7f5617b24c4d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7f4f58005640): is an invalid pointer
Connection ID (thread ID): 44
Status: NOT_KILLED

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.

表损坏,备份也会失败,操作到这个表的时候会导致数据库立即崩溃

定位目标表:

mysqlcheck -u root -p --auto-repair --all-databases

检测到指定表会导致数据库挂掉,仍然不会显示表名,但是能够显示最后一个正常的表,再进入 show tables 看这个表的下一个表就可以了

损坏恢复

mysql表数据文件frm,ibd损坏后的解决办法

现象:数据库无法正常启动,提示表空间或者表其他错误,需要重binlog恢复,如果此时没有对应的binlog,那么注释binlog日志即可。此时只能使用innodb_force_recovery来启动,这个参数有7个级别,其中0-3是允许使用drop,create等命令的,大于等于4级别innodb被设置为只读。所以设置为3后重启数据库,成功链接。

但此想在库中drop或者create表仍然不行,都提示table doesn't exists。 解决办法: 在以正常启动数据库为目标,无所谓数据丢失的前提下。停掉数据库,删除损坏表对应的frm和ibd,复制正常表的frm为原表frm名,然后启动数据库,可以成功drop此表,然后重建表即可。

PS. mysql如果某些bug或者问题导致数据库挂了,或无限重启,那么可以尝试修改innodb_force_recovery为3,如果3仍然不行,可以选择修改为4,此时虽然数据库不可写,但是能够启动库,接着再使用此方法来确定有问题的表

0

评论

博主关闭了当前页面的评论