磁盤問題引起的MySQL問題

收到Nagios通知,公司的MySQL從庫slave出現同步問題。

由於之前試過停電時,也出現類似的問題,懷疑問題是源自主庫master服務器;

登錄主庫後,下意識沒有第一時間檢查mysql,而是查看磁盤空間,

發現mount命令居然不顯示我的數據盤了,奇怪的是還是可以訪問數據目錄

嘗試mount -a提示磁盤busy,

由於該服務器提供的生產服務並不重要,於是嘗試reboot

我猜測重啓會有問題,於是登錄到esxi上去觀察console(該服務器是虛擬機),

果然出現問題,在磁盤檢測時出現提示磁盤不連續,

輸入密碼,然後fsck -y 檢查對應的提示的磁盤

總共有3個盤出現了不連續的情況

修復後,正常重啓,盤也出來了


卻發現mysqld不能啓動了

查看錯誤日誌文件,提示磁盤已滿,無法寫入pid文件

檢查/目錄,果然剩餘空間0,刪掉一些無用的文件,再嘗試啓動mysqld

又報錯,但錯誤信息變化了

160405  9:24:40 [ERROR] /usr/libexec/mysqld: Table './Syslog/SystemEvents' is marked as crashed and should be repaired

很可能由於磁盤不連續的問題導致的。

於是myisamchk -r /data/mysql/Syslog/SystemEvents.MYI

修復了一個index,嘗試啓動成功。

至此主庫恢復正常。


查看從庫的提示,發生了變化

mysql> show slave status\G

Last_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.

大意是你的relay log文件無法解析了,通常是主庫的binlog損壞導致的


我選擇的方案是重做從庫數據

於是把主庫的整庫備份並導入到從庫中去

主庫:

mysqldump -uroot -pPASSWORD -B Syslog -x --events --opt --master-data=1|gzip >/data/Syslog-full-`date +%F`.sql.gz


從庫:

mysql> slave stop;

mysql -u root -pPASSWORD <Syslog-full-2016-04-05.sql

mysql> slave start;

Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G


至此從庫恢復正常。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章