我正在尝试从旧系统中恢复一个损坏的MyISAM表。当突然停电时,该表已损坏。它的行略多于5亿行,大小为23 It (.MYD文件)。
通常,运行这个命令myisamchk -r -v -f table_name
可以修复表,我可以让数据库启动并运行。这一次有点不同。运行此命令将导致以下错误:
- recovering (with sort) MyISAM-table 'table_name'
Data records: 545297330
- Fixing index 1
- Searching for keys, allocating buffer for 596523227 keys
Found block that points outside data file at 24215711712
Wrong bytesec: 49- 52- 57 at 2740875236; Skipped
Wrong bytesec: 49- 53- 56 at 2740875256; Skipped
Found block that points outside data file at 24215711712
Wrong bytesec: 49- 52- 57 at 2740875236; Skipped
Wrong bytesec: 49- 53- 56 at 2740875256; Skipped
myisamchk: error: Key 1 - Found too many records; Can't continue
MyISAM-table 'table_name' is not fixed because of errors
Try fixing it by using the --safe-recover (-o), the --force (-f) option or by not using the --quick (-q) flag
如果我从-o
选项开始,它只是执行一个循环,说明在16412879816的记录中有一个重复的键1,而新的记录是16412879816,在运行了将近8个小时之后,什么都没有改变。
我尝试过REPAIR TABLE table_name;
,它创建一个.TMD
文件,将其填充到33 0B,然后将.TMD
文件重置为0B,然后重新开始。它确实更新了.MYI
文件,但不改变它的大小。10个小时后,一切都没有改变。
我也尝试过REPAIR TABLE table_name USE_FRM;
,它在做了20分钟的事情之后,消耗掉了所有的内存(32 up内存/32 up交换)。
我恢复桌子的其他选择是什么?
我不介意最近写的行的数据丢失。是频繁的遥测数据被聚合,所以最近几次测量丢失不是一个问题。
MariaDB版本: 5.7.33
编辑:似乎有什么东西导致修复在一个循环中运行。
Checking MyISAM file: table_name
Data records: 104616403 Deleted blocks: 0
myisamchk: warning: Table is marked as crashed and last repair failed
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check record links
myisamchk: error: Recordlink that points outside datafile at 24215711712
MyISAM-table 'table_name' is corrupted
Fix it using switch "-r" or "-o"
# myisamchk table_name -r
- recovering (with keycache) MyISAM-table 'table_name'
Data records: 104616403
Found block that points outside data file at 24215711712
Found block that points outside data file at 24215711712
Found block that points outside data file at 24215711712
Found block that points outside data file at 24215711712
Found block that points outside data file at 24215711712
Found block that points outside data file at 24215711712
32027100000000
发布于 2022-08-31 23:43:00
试试看:
在未来,考虑切换到InnoDB。并考虑“立即”总结数据,不要保存超过几个小时/天价值的数据。
由于提到了.TMD
,听起来您的磁盘空间似乎用完了。看看.MYD
和.MYI
的大小。然后确保你至少有那么多的自由空间在两个地方:
tmpdir
指示的文件系统。(这可能有点过火了。)(这两个地方可能是同一个文件系统;取决于操作系统和MySQL配置)。
只需在尝试修复之前删除.MYI
文件即可。如果需要足够的空闲磁盘空间,修复将发现缺少的索引并重新构建它们。
https://dba.stackexchange.com/questions/316313
复制相似问题