MySQL意外斷電,InnoDB數據庫恢復

客戶數據庫在運行中忽然斷電,當服務器重啓發現MySQL沒法啓動,查看日誌,報錯以下:html

151105 11:24:52 mysqld_safe Starting mysqld daemon with databases from /data/mysql/datafile
151105 11:24:52 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
151105 11:24:52 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
151105 11:24:52 InnoDB: The InnoDB memory heap is disabled
151105 11:24:52 InnoDB: Mutexes and rw_locks use GCC atomic builtins
151105 11:24:52 InnoDB: Compressed tables use zlib 1.2.3
151105 11:24:52 InnoDB: Initializing buffer pool, size = 512.0M
151105 11:24:52 InnoDB: Completed initialization of buffer pool
151105 11:24:52 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
151105 11:24:52  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...
151105 11:24:52  InnoDB: ERROR: We were only able to scan the log up to
InnoDB: 2735615488, but a checkpoint was at 2735615806.
InnoDB: It is possible that the database is now corrupt!
InnoDB: 3 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 3 row operations to undo
InnoDB: Trx id counter is 6D84900
InnoDB: Last MySQL binlog file position 0 446116929, file name /data/mysql/binlog/mysql-bin.001288
InnoDB: Cleaning up trx with id 6D7C116
InnoDB: Cleaning up trx with id 6D74419
InnoDB: Cleaning up trx with id 6D6F27E
151105 11:24:52  InnoDB: Waiting for the background threads to start
151105 11:24:52  InnoDB: Assertion failure in thread 140108568532736 in file trx0purge.c line 848
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.
03:24:52 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.
Please help us make Percona Server better by reporting any
bugs at http://bugs.percona.com/

key_buffer_size=402653184
read_buffer_size=4194304
max_used_connections=0
max_threads=2002
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 = 16818378 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/percona-server-5.5.38-35.2/bin/mysqld(my_print_stacktrace+0x2e)[0x7785ae]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld(handle_fatal_signal+0x43a)[0x66a1da]
/lib64/libpthread.so.0[0x379c20f710]
/lib64/libc.so.6(gsignal+0x35)[0x379be32925]
/lib64/libc.so.6(abort+0x175)[0x379be34105]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x814fb0]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x8153f7]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x8e318f]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x8d98d5]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x813c4e]
/usr/local/percona-server-5.5.38-35.2/bin/mysqld[0x809d2c]
/lib64/libpthread.so.0[0x379c2079d1]
/lib64/libc.so.6(clone+0x6d)[0x379bee8b5d]
You may download the Percona Server operations manual by visiting
http://www.percona.com/software/percona-server/. You may find information
in the manual which will help you identify the cause of the crash.
151105 11:24:52 mysqld_safe mysqld from pid file /data/mysql/datafile/mysql.pid ended

分析日誌後發現,數據庫沒法重啓的緣由是由於ibdata1文件損壞,重啓後沒法正常恢復。mysql

如今咱們就須要跳過恢復步驟,修改my.cnf文件,在my.cnf中的[mysqld]中添加sql

innodb_force_recovery = 6
innodb_purge_threads = 0

innodb_force_recovery能夠設置爲1-6,大的數字包含前面全部數字的影響。
1. (SRV_FORCE_IGNORE_CORRUPT):忽略檢查到的corrupt頁。
2. (SRV_FORCE_NO_BACKGROUND):阻止主線程的運行,如主線程須要執行full purge操做,會致使crash。
3. (SRV_FORCE_NO_TRX_UNDO):不執行事務回滾操做。
4. (SRV_FORCE_NO_IBUF_MERGE):不執行插入緩衝的合併操做。
5. (SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重作日誌,InnoDB存儲引擎會將未提交的事務視爲已提交。
6. (SRV_FORCE_NO_LOG_REDO):不執行前滾的操做。shell

再次啓動,若是還沒法啓動則刪除數據目錄datafile下的 ibdata1,ib_logfile*等文件。數據庫

啓動後導出MySQL數據庫,從新恢復便可。服務器

相關文章
相關標籤/搜索