国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

磁盤寫滿導(dǎo)致MySQL復(fù)制失敗的解決方案

瀏覽:2日期:2023-10-04 09:58:59
案例場(chǎng)景

今天在線上發(fā)現(xiàn)一個(gè)問題,由于監(jiān)控沒有覆蓋到,某臺(tái)機(jī)器的磁盤被寫滿了,導(dǎo)致線上MySQL主從復(fù)制出現(xiàn)問題。問題如下:

localhost.(none)>show slave statusG*************************** 1. row *************************** Slave_IO_State: Master_Host: 10.xx.xx.xx Master_User: replica Master_Port: 5511Connect_Retry: 60 Master_Log_File: Read_Master_Log_Pos: 4 Relay_Log_File: relay-bin.001605Relay_Log_Pos: 9489761Relay_Master_Log_File: Slave_IO_Running: No Slave_SQL_Running: No Last_Errno: 13121 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, the server was unable to fetch a keyring key required to open an encrypted relay log file, 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.

于是查看error log,發(fā)現(xiàn)error log中的內(nèi)容如下:

2021-03-31T11:34:39.367173+08:00 11 [Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the ’START SLAVE Syntax’ in the MySQL Manual for more information.2021-03-31T11:34:39.368161+08:00 12 [ERROR] [MY-010596] [Repl] Error reading relay log event for channel ’’: binlog truncated in the middle of event; consider out of disk space2021-03-31T11:34:39.368191+08:00 12 [ERROR] [MY-013121] [Repl] Slave SQL for channel ’’: 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, the server was unable to fetch a keyring key required to open an encrypted relay log file, 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. Error_code: MY-0131212021-03-31T11:34:39.368205+08:00 12 [ERROR] [MY-010586] [Repl] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with 'SLAVE START'. We stopped at log ’mysql-bin.000446’ position 9489626

從描述中可以看到,error log是比較智能的,發(fā)現(xiàn)了磁盤問題,并提示我們需要'consider out of disk space'

解決問題

登錄服務(wù)器,很快就發(fā)現(xiàn)是MySQL所在的服務(wù)器磁盤使用率達(dá)到100%了,問題原因跟error log中的內(nèi)容一致。

現(xiàn)在就解決這個(gè)問題。基本的思路就是清理磁盤文件,然后重新搭建復(fù)制關(guān)系,這個(gè)過程似乎比較簡(jiǎn)單,但是實(shí)際操作中,在搭建復(fù)制關(guān)系的時(shí)候出現(xiàn)了下面的報(bào)錯(cuò):

### 基于gtid的復(fù)制,想重新搭建復(fù)制關(guān)系localhost.(none)>reset slave;ERROR 1371 (HY000): Failed purging old relay logs: Failed during log resetlocalhost.(none)>reset slave all;ERROR 1371 (HY000): Failed purging old relay logs: Failed during log reset

第一步:因?yàn)閺?fù)制是基于gtid進(jìn)行的,所以直接記錄show slave status的狀態(tài)后,就可以重新reset slave,并利用change master語句來重建復(fù)制關(guān)系了。

但是卻出現(xiàn)上面的報(bào)錯(cuò),從報(bào)錯(cuò)信息看是mysql無法完成purge relay log的操作,這看起來不科學(xué)。好吧,既然你自己不能完成purge relay logs的操作,那就讓我來幫你吧。

第二步:手工rm -f 刪除所有的relay log,發(fā)現(xiàn)報(bào)錯(cuò)變成了:

localhost.(none)>reset slave all;ERROR 1374 (HY000): I/O error reading log index file

嗯,好吧,問題沒有得到解決。

然后思考了下,既然不能通過手工reset slave 來清理relay log,直接stop

slave 然后change master行不行呢?

第三步:直接stop slave,然后change master,不執(zhí)行reset slave all的語句,結(jié)果如下:

localhost.(none)>change master to master_host=’10.13.224.31’, -> master_user=’replica’, -> master_password=’eHnNCaQE3ND’, -> master_port=5510, -> master_auto_position=1;ERROR 1371 (HY000): Failed purging old relay logs: Failed during log reset

得,問題依舊。

第四步:反正復(fù)制已經(jīng)報(bào)錯(cuò)斷開了,執(zhí)行個(gè)start slave看看,結(jié)果戲劇性的一幕出現(xiàn)了:

localhost.(none)>start slave;ERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect...Connection id: 262Current database: *** NONE ***Query OK, 0 rows affected (0.01 sec)localhost.(none)>[root@ ~]#

執(zhí)行start slave之后,實(shí)例直接掛了。

到這里,復(fù)制徹底斷開了,從庫(kù)實(shí)例已經(jīng)掛了。

第五步:看看實(shí)例還能不能重啟,嘗試重啟實(shí)例,發(fā)現(xiàn)實(shí)例還能起來。實(shí)例重新起來后,查看復(fù)制關(guān)系,結(jié)果如下:

localhost.(none)>show slave statusG*************************** 1. row *************************** Slave_IO_State: Queueing master event to the relay log Master_Host: 10.xx.xx.xx Master_User: replica Master_Port: 5511Connect_Retry: 60 Master_Log_File: Read_Master_Log_Pos: 4 Relay_Log_File: relay-bin.001605Relay_Log_Pos: 9489761Relay_Master_Log_File: Slave_IO_Running: Yes Slave_SQL_Running: No Last_Errno: 13121 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, the server was unable to fetch a keyring key required to open an encrypted relay log file, 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. Skip_Counter: 0

復(fù)制關(guān)系依舊報(bào)錯(cuò)。

第六步:重新reset slave all看看,結(jié)果成功了。

localhost.(none)>stop slave;Query OK, 0 rows affected (0.00 sec)localhost.(none)>reset slave all;Query OK, 0 rows affected (0.03 sec)

第七步:重新搭建復(fù)制關(guān)系并啟動(dòng)復(fù)制

localhost.(none)>change master to master_host=’10.xx.xx.xx’, -> master_user=’replica’, -> master_password=’xxxxx’, -> master_port=5511, -> master_auto_position=1;Query OK, 0 rows affected, 2 warnings (0.01 sec)localhost.(none)>start slave;Query OK, 0 rows affected (0.00 sec)localhost.(none)>show slave statusG*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.xx.xx.xx Master_User: replica Master_Port: 5511Connect_Retry: 60 ... Slave_IO_Running: Yes Slave_SQL_Running: Yes

發(fā)現(xiàn)實(shí)例的復(fù)制關(guān)系可以建立起來了。

一點(diǎn)總結(jié)

當(dāng)磁盤寫滿的情況發(fā)生之后,mysql服務(wù)無法向元信息表中寫數(shù)據(jù),relay log也可能已經(jīng)不完整了,如果直接清理了服務(wù)器上的磁盤數(shù)據(jù),再去重新change master修改主從復(fù)制關(guān)系,可能會(huì)出現(xiàn)報(bào)錯(cuò),不能直接修復(fù),因?yàn)檫@不是一個(gè)正常的主從復(fù)制關(guān)系斷裂場(chǎng)景。

所以,正確的做法應(yīng)該是:

1、清理服務(wù)器的磁盤

2、重啟復(fù)制關(guān)系斷開的那個(gè)從庫(kù)

3、重新reset slave all、change master來搭建主從復(fù)制關(guān)系即可

如果有更好的方法,還請(qǐng)不吝賜教。

以上就是磁盤寫滿導(dǎo)致MySQL復(fù)制失敗的解決方案的詳細(xì)內(nèi)容,更多關(guān)于MySQL復(fù)制失敗的解決方案的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: MySQL 數(shù)據(jù)庫(kù)
相關(guān)文章:
主站蜘蛛池模板: 欧美色综合高清视频在线 | 久久三级网站 | 免费一级a毛片在线播放视 免费一级α片在线观看 | 国产精品三级手机在线观看 | 亚洲美女在线观看亚洲美女 | 免费高清不卡毛片在线看 | 久久亚洲不卡一区二区 | 日韩欧美中文字幕在线播放 | 手机在线观看精品国产片 | 久久国产网 | 99久久精品免费视频 | 日本一级大毛片a一 | 亚洲免费大全 | 国产精品亚洲一区在线播放 | 日韩免费三级 | 美女一级毛片免费不卡视频 | 久久精品国产第一区二区 | 亚洲一区二区三区四区在线 | 欧美精品综合一区二区三区 | 国内自拍欧美 | 国内自拍第五一页 | 欧美一级鲁丝片 | 爽死你个放荡粗暴小淫货双女视频 | 久久99精品久久久久久青青91 | 欧美大片aaa | 中文字幕一区二区三区久久网站 | www日本高清视频 | 日韩久操 | 韩国免费毛片在线看 | 久久久国产99久久国产一 | 欧美老头老太做爰xxxx | 精品久久久久不卡无毒 | 亚欧在线观看 | 日韩免费毛片全部不收费 | 亚洲欧美一区二区三区在线观看 | 深夜做爰性大片很黄很色视频 | a级片在线观看免费 | 亚洲欧美精品一区二区 | 成人毛片全部免费观看 | a免费网站 | 日韩国产欧美视频 |