您好,登錄后才能下訂單哦!
這篇文章主要講解了“mysql innodb異常如何處理”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“mysql innodb異常如何處理”吧!
為避免再?gòu)钠渌胤綄?dǎo)入這個(gè)數(shù)據(jù)的麻煩,先對(duì)當(dāng)前庫(kù)的數(shù)據(jù)庫(kù)文件做了個(gè)備份(/var/lib/mysql/位置)。接下來(lái)將Percona server 5.7包進(jìn)行了卸載,重新安裝原先老的5.1.71的包,啟動(dòng)mysql服務(wù),提示Unknown/unsupported table type: innodb,無(wú)法正常啟動(dòng)。
110509 12:04:27 InnoDB: Initializing buffer pool, size = 384.0M 110509 12:04:27 InnoDB: Completed initialization of buffer pool InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes InnoDB: than specified in the .cnf file 0 157286400 bytes! 110509 12:04:27 [ERROR] Plugin 'InnoDB' init function returned error. 110509 12:04:27 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 110509 12:04:27 [ERROR] Unknown/unsupported table type: innodb 110509 12:04:27 [ERROR] Aborting 110509 12:04:27 [Note] /usr/sbin/mysqld: Shutdown complete
刪除/var/lib/mysql/目錄,重新啟動(dòng)數(shù)據(jù)庫(kù)服務(wù),并初始化,發(fā)現(xiàn)正常,show engines能發(fā)現(xiàn)有innodb引擎。再將數(shù)據(jù)庫(kù)停掉,將之前備份的/var/lib/mysql/目錄的內(nèi)容覆蓋當(dāng)前位置的內(nèi)容,重啟。又發(fā)現(xiàn)不能進(jìn)行啟動(dòng),報(bào)錯(cuò)內(nèi)容和剛剛一樣。
/var/lib/mysql目錄內(nèi)容的結(jié)構(gòu)如下:
-rw-rw---- 1 mysql mysql 10485760 2月 26 18:10 ibdata1 -rw-rw---- 1 mysql mysql 5242880 2月 26 18:10 ib_logfile0 -rw-rw---- 1 mysql mysql 5242880 2月 26 17:20 ib_logfile1 drwx------ 2 mysql mysql 4096 2月 26 17:20 mysql drwx------ 2 mysql mysql 4096 2月 26 17:24 wiki
wiki目錄是測(cè)試數(shù)據(jù)的庫(kù),ibdata1文件為數(shù)據(jù)文件,ib開頭的兩個(gè)文件為日志文件,mysql 目錄下為系統(tǒng)庫(kù)相關(guān)的東西 。再次使用初始化的數(shù)據(jù),并將wiki目錄和ibdata1文件覆蓋到/var/lib/mysql 目錄下,可以正常啟動(dòng),也可以正常登錄。
不過(guò)在通過(guò)mysqldump備份時(shí),又提示unknow table engine “Innodb” 。登錄后,查看當(dāng)前所有的引擎類型,發(fā)現(xiàn)其中果然不存在innodb類型:
通過(guò)alter命令修改其中一個(gè)表的類型為MyISAM ,發(fā)現(xiàn)仍然報(bào)錯(cuò)。
通過(guò) find 查找發(fā)現(xiàn)/usr/lib64/mysql/plugin/目錄下有ha_innodb_plugin.so文件。印象中mysql5以后的版本支持在線插件安裝 。通過(guò)下面查看確認(rèn),果然支持:
使用如下命令加載時(shí),發(fā)現(xiàn)不成功:
install plugin innodb soname 'ha_innodb.so';
在/etc/my.cnf中增加如下配置:
plugin-load=innodb=ha_innodb_plugin.so plugin_dir=/usr/lib64/mysql/plugin/ default-storage-engine=InnoDB
發(fā)現(xiàn)仍啟動(dòng)失敗。查看mysql-error.log發(fā)現(xiàn)有如下內(nèi)容:
InnoDB: Database page corruption on disk or a failed InnoDB: file read of page 7. 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-innodb-recovery.html
打開forcing-innodb-recovery官方頁(yè)面,發(fā)現(xiàn)可以通過(guò)指定innodb_force_recovery參數(shù),進(jìn)行強(qiáng)制啟動(dòng)和恢復(fù)。在/etc/my.cnf中增加如下內(nèi)容:
innodb_force_recovery=6
重新啟動(dòng)成功了。通過(guò)mysqldump備份也沒(méi)有問(wèn)題,將備份數(shù)據(jù)導(dǎo)入其他主機(jī)發(fā)現(xiàn)也正常可以測(cè)試。
這下就好搞了,將mysql徹底刪除,重新安裝Percona server 5.7,安裝完后,建庫(kù),還原數(shù)據(jù),程序重新連接,一切OK。
感謝各位的閱讀,以上就是“mysql innodb異常如何處理”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)mysql innodb異常如何處理這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。