有一個crm系統(tǒng),其中有做了一個報表統(tǒng)計,其中源碼和數(shù)據(jù)庫放在同意一臺機子上,數(shù)據(jù)庫用mysql;但在今天突然報錯頁面提示不能用root@locahost連接
用命令行登錄,提示can't connection to mysql;再檢查端口發(fā)現(xiàn),數(shù)據(jù)庫已經關閉;
現(xiàn)象:
crm可以登錄,點擊其他頁面正常,當點擊報表查看報表數(shù)據(jù)時就報錯,并且數(shù)據(jù)庫崩潰
初步分析認為程序錯誤或者數(shù)據(jù)庫錯誤導致數(shù)據(jù)庫崩潰從而自動斷開
問題解決:
1.查看mysql數(shù)據(jù)庫錯誤日志內容如下:
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 5761.
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.1/en/forcing-recovery.html
InnoDB: about forcing recovery.
InnoDB: Ending processing because of a corrupt database page.
2.網(wǎng)上搜索該問題,原因為:
數(shù)據(jù)庫中表損壞導致數(shù)據(jù)訪問錯誤,從而導致數(shù)據(jù)庫崩潰;mysql中check table 發(fā)現(xiàn)表有損壞,但表是innodb類型不能修復
網(wǎng)上解決方法為:在my.ini中mysqld下添加innodb_force_recovery=4
說明:
1(SRV_FORCE_IGNORE_CORRUPT):忽略檢查到的corrupt頁。
2(SRV_FORCE_NO_BACKGROUND):阻止主線程的運行,如主線程需要執(zhí)行full purge操作,會導致crash。
3(SRV_FORCE_NO_TRX_UNDO):不執(zhí)行事務回滾操作。
4(SRV_FORCE_NO_IBUF_MERGE):不執(zhí)行插入緩沖的合并操作。
5(SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存儲引擎會將未提交的事務視為已提交。
6(SRV_FORCE_NO_LOG_REDO):不執(zhí)行前滾的操作。
3.重啟數(shù)據(jù)庫后問題依然存在,再對照錯誤發(fā)現(xiàn)自己的錯誤為corrupt類型,所以認為應將innodb_force_recovery設置為1,于是my.ini中innodb_force_recovery值改為1,重啟數(shù)據(jù)庫
4.發(fā)現(xiàn)重啟后問題依然存在
5.于是再做如下操作:(重要)
修改my.ini 將innodb_force_recovery這行注釋
#innodb_force_recovery=1
然后重啟數(shù)據(jù)庫,在停止數(shù)據(jù)庫,在修改my.ini,去掉注釋
innodb_force_recovery=1
重啟數(shù)據(jù)庫,問題解決
ps:對于第五步的操作一直沒想明白,為什么要先注釋掉重啟后在打開才能生效,個人認為可能是有什么地方緩存導致的吧。在此記錄,繼續(xù)探索問題的根源。。
摘自 冰糖葫蘆的專欄
bitsCN.com聲明:本網(wǎng)頁內容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com