MySQL奔溃,InnoDB文件损坏修复记录

报错日志文件:

bash 复制代码
-----------------------------------------

161108 23:36:45 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var

2019-12-01 23:36:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-12-01 23:36:46 5497 [Note] Plugin 'FEDERATED' is disabled.

2019-12-01 23:36:46 7f11c48e1720 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.

2019-12-01 23:36:46 5497 [Note] InnoDB: Using atomics to ref count buffer pool pages

2019-12-01 23:36:46 5497 [Note] InnoDB: The InnoDB memory heap is disabled

2019-12-01 23:36:46 5497 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2019-12-01 23:36:46 5497 [Note] InnoDB: Memory barrier is not used

2019-12-01 23:36:46 5497 [Note] InnoDB: Compressed tables use zlib 1.2.3

2019-12-01 23:36:46 5497 [Note] InnoDB: Using CPU crc32 instructions

2019-12-01 23:36:46 5497 [Note] InnoDB: Initializing buffer pool, size = 16.0M

2019-12-01 23:36:46 5497 [Note] InnoDB: Completed initialization of buffer pool

InnoDB: Database page corruption on disk or a failed

InnoDB: file read of page 5.

InnoDB: You may have to recover from a backup.

2019-12-01 23:36:46 7f11c48e1720 InnoDB: Page dump in ascii and hex (16384 bytes):

 len 16384; hex 7478d078000000050000000000000000000000000f271f4d000700000000000000000000000000000000001b4000000000000000000200f20000000000000006000000000000002d000000000000002e000000000000002f0000000000000030000000000(省略很多类似代码)

InnoDB: End of page dump

2019-12-01 23:36:46 7f11c48e1720 InnoDB: uncompressed page, stored checksum in field1 1954074744, calculated checksums for field1: crc32 993334256, innodb 2046145943, none 3735928559, stored checksum in field2 1139795846, calculated checksums for field2: crc32 993334256, innodb 1606613742, none 3735928559, page LSN 0 254222157, low 4 bytes of LSN at page end 254221236, page number (if stored to page already) 5, space id (if created with >= MySQL-4.1.1 and stored already) 0

InnoDB: Page may be a transaction system page

InnoDB: Database page corruption on disk or a failed

InnoDB: file read of page 5.

InnoDB: You may have to recover from a backup.

InnoDB: It is also possible that your operating

InnoDB: system has corrupted its own file cache

InnoDB: and rebooting your computer removes the

InnoDB: error.

InnoDB: If the corrupt page is an index page

InnoDB: you can also try to fix the corruption

InnoDB: by dumping, dropping, and reimporting

InnoDB: the corrupt table. You can use CHECK

InnoDB: TABLE to scan your table for corruption.

InnoDB: See also http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html

InnoDB: about forcing recovery.

InnoDB: Ending processing because of a corrupt database page.

2019-12-01 23:36:46 7f11c48e1720  InnoDB: Assertion failure in thread 139714288817952 in file buf0buf.cc line 4201

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.6/en/forcing-innodb-recovery.html

InnoDB: about forcing recovery.

03:36:46 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 have already crashed,

something is definitely wrong and this may fail.

key_buffer_size=16777216

read_buffer_size=262144

max_used_connections=0

max_threads=1000

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 = 798063 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/mysql/bin/mysqld(my_print_stacktrace+0x35)[0x8e64b5]

/usr/local/mysql/bin/mysqld(handle_fatal_signal+0x41b)[0x652fbb]

/lib64/libpthread.so.0(+0xf7e0)[0x7f11c44c77e0]

/lib64/libc.so.6(gsignal+0x35)[0x7f11c315d625]

/lib64/libc.so.6(abort+0x175)[0x7f11c315ee05]

/usr/local/mysql/bin/mysqld[0xa585c5]

/usr/local/mysql/bin/mysqld[0xa6c7b4]

/usr/local/mysql/bin/mysqld[0xa6cbc7]

/usr/local/mysql/bin/mysqld[0xa5bce2]

/usr/local/mysql/bin/mysqld[0xa1e2ba]

/usr/local/mysql/bin/mysqld[0xa0bf60]

/usr/local/mysql/bin/mysqld[0x95a427]

/usr/local/mysql/bin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x48)[0x58f788]

/usr/local/mysql/bin/mysqld[0x6e4a36]

/usr/local/mysql/bin/mysqld(_Z11plugin_initPiPPci+0xb3e)[0x6e826e]

/usr/local/mysql/bin/mysqld[0x582d85]

/usr/local/mysql/bin/mysqld(_Z11mysqld_mainiPPc+0x4d8)[0x587d18]

/lib64/libc.so.6(__libc_start_main+0xfd)[0x7f11c3149d5d]

/usr/local/mysql/bin/mysqld[0x57a019]

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.

161108 23:36:46 mysqld_safe mysqld from pid file /usr/local/mysql/var/VM_241_49_centos.pid ended

------------------------------------------------------------------------------

修复方法:

1、修改 my.cnf 配置文件

bash 复制代码
[mysqld]
# 可以是 1-6 几个数字,重启MySQL
innodb_force_recovery = 6 

2、备份数据库、删除原数据

bash 复制代码
mysqldump -uroot -p123 test > test.sql

删除 MySQL数据目录下,对应数据库文件夹下的所有文件(前提是确保已成功备份),最好的做法是在目录下创建一个 backup 的文件夹,将所有文件移动到这个目录

3、将 ib_logfile0、ib_logfile1、ibdata1 移动到 backup 文件夹

bash 复制代码
mkdir backup
bash 复制代码
mv ib_logfile* backup
bash 复制代码
mv ibdata1 backup

4、将 my.cnf 中innodb_force_recovery = 1 或 2-6几个数字这行配置删除或者配置为innodb_force_recovery = 0,重启MySQL服务

5、将数据导入MySQL数据库

bash 复制代码
mysql -uroot -p123 test < test.sql
相关推荐
王道长服务器 | 亚马逊云39 分钟前
帝国CMS + AWS:老牌内容系统的新生之路
服务器·网络·数据库·云计算·aws
李慕婉学姐1 小时前
Springboot的民宿管理系统的设计与实现29rhm9uh(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·spring boot·后端
LB21122 小时前
Redis黑马点评 Feed流
数据库·redis·缓存
喝杯牛奶丶3 小时前
MySQL隔离级别:大厂为何偏爱RC?
java·数据库·mysql·面试
一 乐4 小时前
二手车销售|汽车销售|基于SprinBoot+vue的二手车交易系统(源码+数据库+文档)
java·前端·数据库·vue.js·后端·汽车
Databend4 小时前
BendSQL v0.30.3 Web UI 功能介绍
数据库
gAlAxy...4 小时前
Spring 从 0 → 1 保姆级笔记:IOC、DI、多配置、Bean 生命周期一次讲透
数据库·sqlserver
苦学编程的谢4 小时前
Redis_5_单线程模型
数据库·redis·缓存
xuejianxinokok5 小时前
可能被忽略的 pgvector 各种坑
数据库·后端
拾忆,想起5 小时前
TCP粘包拆包全解析:数据流中的“藕断丝连”与“一刀两断”
java·网络·数据库·网络协议·tcp/ip·哈希算法