本文主要描述MySQL服务器断电,启动之后,数据库无法启动,使用innodb_force_recovery=6进行恢复的案例。

 


       MySQL服务器遇断电,重启之后,数据库无法打开。具体报错信息如下:

140918 13:56:02 mysqld_safe Number of processes running now: 0

140918 13:56:02 mysqld_safe mysqld restarted

140918 13:56:02 InnoDB: The InnoDB memory heap is disabled

140918 13:56:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins

140918 13:56:02 InnoDB: Compressed tables use zlib 1.2.3

140918 13:56:02 InnoDB: Initializing buffer pool, size = 128.0M

140918 13:56:02 InnoDB: Completed initialization of buffer pool

140918 13:56:02 InnoDB: highest supported file format is Barracuda.

InnoDB: Log scan progressed past the checkpoint lsn 67376606

140918 13:56:02  InnoDB: Database was not shut down normally!

InnoDB: Starting crash recovery.

InnoDB: Reading tablespace information from the .ibd files...

InnoDB: Restoring possible half-written data pages from the doublewrite

InnoDB: buffer...

InnoDB: Doing recovery: scanned up to log sequence number 67712828

140918 13:56:02  InnoDB: Starting an apply batch of log records to the database...

InnoDB: Progress in percents: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

InnoDB: Apply batch completed

140918 13:56:03  InnoDB: Waiting for the background threads to start

140918 13:56:04 InnoDB: 1.1.8 started; log sequence number 67712828

140918 13:56:04 [Note] Recovering after a crash using /data/mysql/binlog/mysql-bin

140918 13:56:04 [Note] Starting crash recovery...

140918 13:56:04 [Note] Crash recovery finished.

140918 13:56:04  InnoDB: Assertion failure in thread 1245067584 in file trx0purge.c line 829

InnoDB: Failing assertion: purge_sys->purge_trx_no <= purge_sys->rseg->last_trx_no

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.

05:56:04 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=8388608

read_buffer_size=131072

max_used_connections=0

max_threads=151

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 = 338489 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...

140918 13:56:04 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306

stack_bottom = 0 thread_stack 0x40000

/usr/local/mysql5.5/bin/mysqld(my_print_stacktrace+0x2e)[0x76ad1e]

140918 13:56:04 [Note]   - '0.0.0.0' resolves to '0.0.0.0';

140918 13:56:04 [Note] Server socket created on IP: '0.0.0.0'.

/usr/local/mysql5.5/bin/mysqld(handle_fatal_signal+0x386)[0x655ba6]

/lib64/libpthread.so.0[0x3519e0eb70]

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

/lib64/libc.so.6(abort+0x110)[0x3519231d10]

/usr/local/mysql5.5/bin/mysqld[0x7ab5d4]

/usr/local/mysql5.5/bin/mysqld[0x7ad219]

/usr/local/mysql5.5/bin/mysqld[0x86a3cf]

/usr/local/mysql5.5/bin/mysqld[0x8617ee]

/usr/local/mysql5.5/bin/mysqld[0x7aad55]

140918 13:56:04 [Warning] 'user' entry 'root@wordpress' ignored in --skip-name-resolve mode.

140918 13:56:04 [Warning] 'user' entry '@wordpress' ignored in --skip-name-resolve mode.

/usr/local/mysql5.5/bin/mysqld[0x79f070]

140918 13:56:04 [Warning] 'proxies_priv' entry '@ root@wordpress' ignored in --skip-name-resolve mode.

/usr/local/mysql5.5/bin/mysqld[0x7a2836]

/lib64/libpthread.so.0[0x3519e0673d]

/lib64/libc.so.6(clone+0x6d)[0x35192d44bd]

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.



          看到这个报错,提示可能是由于表空间数据文件报错引起的无法进行前滚或回滚,从而数据库无法打开。
         由于数据库整体文件不是太大,就几个G,因此尝试了将该数据文件拷贝到另一个地方,编辑好参数文件等一些列工作。(因为这份数据是拷贝,尝试这样做一下,做坏了耶不要紧。如果真实数据只有一份,可别上来就这么干,一定要分析清楚了问题所在,再动手。)
在参数文件中加入innodb_force_recovery=6 ,然后尝试启动mysqld,结果起来了。 这时候数据库只能进行查询,使用 mysqldump将数据导出,然后重新搭建一套新的环境。
至于断电后那部分的数据,可以尝试从binlog中解析一下,然后再对比数据库中,查看是否有丢失的数据,具体的 此处不再详述。

 

 

via.http://blog.itpub.net/26355921/viewspace-1273287/

最后修改:2017 年 07 月 26 日 05 : 17 AM