mysql - 尝试修复 MariaDB 上损坏的 InnoDB 表

标签 mysql mariadb innodb

我的 MariaDB 数据库已损坏。腐败是由于停电造成的。

如果不放置 innodb_force_recovery,我将无法启动 MariaDB。我已将其设置为 3。

它是InnoDB,所以我无法修复它。它应该自己完成。

当我尝试转储表时,出现以下错误:

mysqldump: Error 1034: Index for table 'statistics' is corrupt; try to repair it when dumping table `statistics` at row: 36157

此时我遇到了困难,因为我不知道如何修复索引。

尝试按照 Georg mariadb-check 命令的建议运行,但出现以下错误:

2022-06-03 15:08:15 4 [ERROR] InnoDB: Space id and page no stored in the page, read in are [page id: space=201, page number=30781], should be [page id: space=201, page number=32829]
2022-06-03 15:08:15 4 [ERROR] InnoDB: Space id and page no stored in the page, read in are [page id: space=201, page number=30721], should be [page id: space=201, page number=32769]
2022-06-03 15:08:15 4 [ERROR] [FATAL] InnoDB: Trying to read page number 2188681215 in space 201, space name homeassistant/states, which is outside the tablespace bounds. Byte offset 0, len 16384
220603 15:08:15 [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 https://mariadb.com/kb/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: 10.4.19-MariaDB-1:10.4.19+maria~focal
key_buffer_size=16777216
read_buffer_size=262144
max_used_connections=1
max_threads=66
thread_count=2
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68686 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x7f3c000c48
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 = 0x7f843028b8 thread_stack 0x30000
mysqld(my_print_stacktrace+0x30)[0x55886ff4c0]
mysqld(handle_fatal_signal+0x49c)[0x55882085b4]
linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0x7f87a4378c]
/lib/aarch64-linux-gnu/libc.so.6(gsignal+0xe0)[0x7f870fa138]
/lib/aarch64-linux-gnu/libc.so.6(abort+0x110)[0x7f870e6d68]
mysqld(+0xb241a0)[0x55884d41a0]
mysqld(+0x5a1724)[0x5587f51724]
mysqld(+0xbc3728)[0x5588573728]
mysqld(+0xb81184)[0x5588531184]
mysqld(+0xb5e44c)[0x558850e44c]
mysqld(+0xb39644)[0x55884e9644]
mysqld(+0x59d0d8)[0x5587f4d0d8]
mysqld(+0xb9fa84)[0x558854fa84]
mysqld(+0xba0008)[0x5588550008]
mysqld(+0xb913e8)[0x55885413e8]
mysqld(+0x9ffcb4)[0x55883afcb4]
mysqld(_ZN7handler7ha_openEP5TABLEPKcijP11st_mem_rootP4ListI6StringE+0x58)[0x558820e0b8]
mysqld(_Z21open_table_from_shareP3THDP11TABLE_SHAREPK25st_mysql_const_lex_stringjjjP5TABLEbP4ListI6StringE+0x628)[0x55880d5f30]
mysqld(_Z10open_tableP3THDP10TABLE_LISTP18Open_table_context+0x6dc)[0x5587fcb1f4]
mysqld(_Z11open_tablesP3THDRK14DDL_options_stPP10TABLE_LISTPjjP19Prelocking_strategy+0x9f8)[0x5587fce378]
mysqld(_Z20open_and_lock_tablesP3THDRK14DDL_options_stP10TABLE_LISTbjP19Prelocking_strategy+0x38)[0x5587fceb30]
mysqld(+0x758608)[0x5588108608]
mysqld(+0x7595dc)[0x55881095dc]
mysqld(_ZN19Sql_cmd_check_table7executeEP3THD+0x8c)[0x558810b24c]
mysqld(_Z21mysql_execute_commandP3THD+0xd80)[0x5588024370]
mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x1f8)[0x558802a200]
mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0xfb0)[0x558802c008]
mysqld(_Z10do_commandP3THD+0xfc)[0x558802de34]
mysqld(_Z24do_handle_one_connectionP7CONNECT+0x290)[0x55880feaf8]
mysqld(handle_one_connection+0x44)[0x55880fec1c]
/lib/aarch64-linux-gnu/libpthread.so.0(+0x84fc)[0x7f874e24fc]
/lib/aarch64-linux-gnu/libc.so.6(+0xd467c)[0x7f8719767c]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f3c0118f0): CHECK TABLE `events`
Connection ID (thread ID): 4
Status: NOT_KILLED
Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
information that should help you find out what is causing the crash.
Writing a core file...
Working directory at /var/lib/mysql
Resource Limits:
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        unlimited            unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             unlimited            unlimited            processes
Max open files            1048576              1048576              files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       29948                29948                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us
Core pattern: |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h

最佳答案

  1. 进行备份

  2. 检查哪些表可能有损坏的索引: mariadb-check -c 数据库

  3. 强制重建 优化表损坏表

关于mysql - 尝试修复 MariaDB 上损坏的 InnoDB 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72488735/

相关文章:

mysql - 如何在 MySQL SUM 子查询中创建可用的别名

php - 在 MySQL 数据库的 PHP 中使用 MERGE INTO 语句的问题

mysql - 是否可以借助阿里巴巴Quick BI对MariaDB中存储的数据进行实时分析?

mysql - 我的 MariaDB 中没有 OQGraph?

php - 在队列 MYSQL 中运行查询

mysql - 如何将所有 InnoDB 表转换为 MyISAM?

mysql - 如何恢复Innodb数据库?

php - 一个查询中的多个 Mysql 更新

mysql - Mariadb 5.5 比 MySQL 5.1 慢

python - 查询集合