最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

磁盤(pán)寫(xiě)滿(mǎn)導(dǎo)致MySQL復(fù)制失敗的解決方案

 更新時(shí)間:2021年04月01日 14:19:02   作者:DBA隨筆  
這篇文章主要介紹了磁盤(pán)寫(xiě)滿(mǎn)導(dǎo)致MySQL復(fù)制失敗的解決方案,幫助大家更好的理解和學(xué)習(xí)使用MySQL,感興趣的朋友可以了解下

案例場(chǎng)景

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

localhost.(none)>show slave status\G
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 10.xx.xx.xx
                  Master_User: replica
                  Master_Port: 5511
                Connect_Retry: 60
              Master_Log_File:
          Read_Master_Log_Pos: 4
               Relay_Log_File: relay-bin.001605
                Relay_Log_Pos: 9489761
        Relay_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 space

2021-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-013121

2021-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)了磁盤(pán)問(wèn)題,并提示我們需要"consider out of disk space"

解決問(wèn)題

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

      現(xiàn)在就解決這個(gè)問(wèn)題?;镜乃悸肪褪乔謇泶疟P(pán)文件,然后重新搭建復(fù)制關(guān)系,這個(gè)過(guò)程似乎比較簡(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 reset

localhost.(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語(yǔ)句來(lái)重建復(fù)制關(guān)系了。

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

第二步:手工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

嗯,好吧,問(wèn)題沒(méi)有得到解決。

然后思考了下,既然不能通過(guò)手工reset slave 來(lái)清理relay log,直接stop

slave 然后change master行不行呢?

第三步:直接stop slave,然后change master,不執(zhí)行reset slave all的語(yǔ)句,結(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

得,問(wèn)題依舊。

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

localhost.(none)>start slave;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    262
Current database: *** NONE ***


Query OK, 0 rows affected (0.01 sec)


localhost.(none)>
[root@ ~]#

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

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

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

localhost.(none)>show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Queueing master event to the relay log
                  Master_Host: 10.xx.xx.xx
                  Master_User: replica
                  Master_Port: 5511
                Connect_Retry: 60
              Master_Log_File: 
          Read_Master_Log_Pos: 4
               Relay_Log_File: relay-bin.001605
                Relay_Log_Pos: 9489761
        Relay_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 status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.xx.xx.xx
                  Master_User: replica
                  Master_Port: 5511
                Connect_Retry: 60
                          ...
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

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

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

    當(dāng)磁盤(pán)寫(xiě)滿(mǎn)的情況發(fā)生之后,mysql服務(wù)無(wú)法向元信息表中寫(xiě)數(shù)據(jù),relay log也可能已經(jīng)不完整了,如果直接清理了服務(wù)器上的磁盤(pán)數(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ù)器的磁盤(pán)

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

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

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

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

相關(guān)文章

  • pt-kill 常用殺進(jìn)程參數(shù)介紹

    pt-kill 常用殺進(jìn)程參數(shù)介紹

    這篇文章主要介紹了pt-kill 常用殺進(jìn)程參數(shù)介紹,需要的朋友可以參考下
    2016-04-04
  • mysql 實(shí)現(xiàn)添加時(shí)間自動(dòng)添加更新時(shí)間自動(dòng)更新操作

    mysql 實(shí)現(xiàn)添加時(shí)間自動(dòng)添加更新時(shí)間自動(dòng)更新操作

    這篇文章主要介紹了mysql 實(shí)現(xiàn)添加時(shí)間自動(dòng)添加更新時(shí)間自動(dòng)更新操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-01-01
  • Linux系統(tǒng)下mysql的徹底卸載步驟

    Linux系統(tǒng)下mysql的徹底卸載步驟

    MySQL是一款常用的關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng),但是在使用過(guò)程中,有時(shí)候需要卸載MySQL,有些用戶(hù)在卸載MySQL時(shí)會(huì)遇到一些問(wèn)題,這篇文章主要給大家介紹了關(guān)于Linux系統(tǒng)下mysql的徹底卸載的相關(guān)資料,需要的朋友可以參考下
    2024-07-07
  • Mysql?安裝及my.ini的創(chuàng)建過(guò)程

    Mysql?安裝及my.ini的創(chuàng)建過(guò)程

    這篇文章主要介紹了Mysql?安裝及my.ini的創(chuàng)建過(guò)程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • MySQL 外鍵(FOREIGN KEY)用法案例詳解

    MySQL 外鍵(FOREIGN KEY)用法案例詳解

    這篇文章主要介紹了MySQL 外鍵(FOREIGN KEY)用法案例詳解,本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • 利用JuiceFS使MySQL?備份驗(yàn)證性能提升?10?倍

    利用JuiceFS使MySQL?備份驗(yàn)證性能提升?10?倍

    這篇文章主要介紹了如何讓?MySQL?備份驗(yàn)證性能提升?10?倍,JuiceFS?非常適合用來(lái)做?MySQL?物理備份,通過(guò)不斷調(diào)整?XtraBackup?的參數(shù)和?JuiceFS?的掛載參數(shù),在一個(gè)小時(shí)內(nèi)將時(shí)間縮短到原先的?1/10,下文一起來(lái)看相關(guān)內(nèi)容的詳細(xì)介紹吧
    2022-03-03
  • MySQL間隙鎖解決幻讀問(wèn)題

    MySQL間隙鎖解決幻讀問(wèn)題

    本文主要介紹了MySQL間隙鎖解決幻讀問(wèn)題,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-06-06
  • linux下mysql忘記密碼的解決方法

    linux下mysql忘記密碼的解決方法

    這篇文章主要為大家詳細(xì)介紹了linux下mysql忘記密碼的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-08-08
  • MySQL不用like+%實(shí)現(xiàn)模糊查詢(xún)

    MySQL不用like+%實(shí)現(xiàn)模糊查詢(xún)

    本文主要介紹了MySQL不用like+%實(shí)現(xiàn)模糊查詢(xún),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • mysql中關(guān)于覆蓋索引的知識(shí)點(diǎn)總結(jié)

    mysql中關(guān)于覆蓋索引的知識(shí)點(diǎn)總結(jié)

    在本篇文章里小編給大家整理的是一篇關(guān)于mysql中關(guān)于覆蓋索引的知識(shí)點(diǎn)總結(jié)內(nèi)容,有需要的朋友們學(xué)習(xí)參考下。
    2020-08-08

最新評(píng)論

宜宾县| 休宁县| 佛坪县| 洱源县| 建湖县| 郁南县| 同心县| 建德市| 南川市| 弥渡县| 喀喇| 福海县| 绥芬河市| 宁陕县| 邢台县| 宽城| 兰坪| 大姚县| 富源县| 大余县| 靖西县| 息烽县| 潢川县| 宾阳县| 陆河县| 洪湖市| 济阳县| 四会市| 灵寿县| 新乡县| 喀喇| 宜丰县| 任丘市| 清水县| 蕲春县| 娱乐| 赫章县| 彭水| 平湖市| 富裕县| 陆丰市|