mysql数据库 slave复制异常问题解决办法

小浪SEO博客 专注SEO优化思维、SEO技术的实战分享类博客~

slave是主从复制了,但小编在测试mysql slave主从复制出现了问题了,在此PHP粉丝网小编来为各位介绍mysql数据库 slave复制异常问题解决办法,希望文章对各位有用.

以下是两种slave复制异常的情况。导致的原因都是由于跨机房同步,slave的机房突然掉电导致的。

案例一:这个错误大原因是Read_Master_Log_Pos: 1028687822的pos号在主库上是没有的.

处理方法:获取这个pos号的前一个pos号,从新开启同步,这里注意如果是row模式的话就没有问题.如果是mix的或者statement的话,就需要去分析binlog,确认具体执行到哪个pos号了,不然可能会导致数据不一致.

  1. (andy:db:)[(none)]11:18:39>showslavestatus\G
  2. ***************************1.row***************************
  3. Slave_IO_State:
  4. Master_Host:192.168.11.24
  5. Master_User:slave
  6. Master_Port:3306
  7. Connect_Retry:10
  8. Master_Log_File:mysql-bin.000342
  9. Read_Master_Log_Pos:1028687822
  10. Relay_Log_File:localhost-relay-bin.000767
  11. Relay_Log_Pos:4
  12. Relay_Master_Log_File:mysql-bin.000342
  13. Slave_IO_Running:No
  14. Slave_SQL_Running:Yes
  15. Replicate_Do_DB:
  16. Replicate_Ignore_DB:
  17. Replicate_Do_Table:
  18. Replicate_Ignore_Table:
  19. Replicate_Wild_Do_Table:
  20. Replicate_Wild_Ignore_Table:
  21. Last_Errno:0
  22. Last_Error:
  23. Skip_Counter:0
  24. Exec_Master_Log_Pos:1028687822
  25. Relay_Log_Space:120
  26. Until_Condition:None
  27. Until_Log_File:
  28. Until_Log_Pos:0
  29. Master_SSL_Allowed:No
  30. Master_SSL_CA_File:
  31. Master_SSL_CA_Path:
  32. Master_SSL_Cert:
  33. Master_SSL_Cipher:
  34. Master_SSL_Key:
  35. Seconds_Behind_Master:NULL
  36. Master_SSL_Verify_Server_Cert:No
  37. Last_IO_Errno:1236
  38. Last_IO_Error:Gotfatalerror1236frommasterwhenreadingdatafrombinarylog:‘Clientrequestedmastertostartreplicationfromposition>filesize;thefirstevent‘mysql-bin.000342′at1028687822,thelasteventreadfrom‘./mysql-bin.000342′at4,thelastbytereadfrom‘./mysql-bin.000342′at4.’
  39. Last_SQL_Errno:0
  40. Last_SQL_Error:
  41. Replicate_Ignore_Server_Ids:
  42. Master_Server_Id:1024
  43. Master_UUID:e9143523-c116-11e2-a8a1-0022195d25da--phpfensi.com
  44. Master_Info_File:/usr/local/mysql-6/data/master.info
  45. SQL_Delay:0
  46. SQL_Remaining_Delay:NULL
  47. Slave_SQL_Running_State:Slavehasreadallrelaylog;waitingfortheslaveI/Othreadtoupdateit
  48. Master_Retry_Count:86400
  49. Master_Bind:
  50. Last_IO_Error_Timestamp:14072506:55:26
  51. Last_SQL_Error_Timestamp:
  52. Master_SSL_Crl:
  53. Master_SSL_Crlpath:
  54. Retrieved_Gtid_Set:
  55. Executed_Gtid_Set:
  56. Auto_Position:0
  57. 1rowinset(0.00sec)

案例二:这个是由于slave的relay-log损坏了.可以考虑使用Exec_Master_Log_Pos: 439512771pos号,从新开启同步.或者使用relay_log_recovery=ON参数启动.

  1. (root:bi:)[(none)]10:56:01>showslavestatus\G
  2. ***************************1.row***************************
  3. Slave_IO_State:Waitingformastertosendevent
  4. Master_Host:172.20.100.16
  5. Master_User:slave
  6. Master_Port:3306
  7. Connect_Retry:10
  8. Master_Log_File:mysql-bin.000076
  9. Read_Master_Log_Pos:474667384
  10. Relay_Log_File:localhost-relay-bin.000137
  11. Relay_Log_Pos:212337426
  12. Relay_Master_Log_File:mysql-bin.000076
  13. Slave_IO_Running:Yes
  14. Slave_SQL_Running:No
  15. Replicate_Do_DB:
  16. Replicate_Ignore_DB:
  17. Replicate_Do_Table:
  18. Replicate_Ignore_Table:
  19. Replicate_Wild_Do_Table:
  20. Replicate_Wild_Ignore_Table:
  21. Last_Errno:1594
  22. Last_Error:Relaylogreadfailure:Couldnotparserelaylogevententry.Thepossiblereasonsare:themaster’sbinarylogiscorrupted(youcancheckthisbyrunning‘mysqlbinlog’onthebinarylog),theslave’srelaylogiscorrupted(youcancheckthisbyrunning‘mysqlbinlog’ontherelaylog),anetworkproblem,orabuginthemaster’sorslave’sMySQLcode.Ifyouwanttocheckthemaster’sbinarylogorslave’srelaylog,youwillbeabletoknowtheirnamesbyissuing‘SHOWSLAVESTATUS’onthisslave.
  23. Skip_Counter:0
  24. Exec_Master_Log_Pos:439512771
  25. Relay_Log_Space:474669681
  26. Until_Condition:None
  27. Until_Log_File:
  28. Until_Log_Pos:0
  29. Master_SSL_Allowed:No
  30. Master_SSL_CA_File:
  31. Master_SSL_CA_Path:
  32. Master_SSL_Cert:
  33. Master_SSL_Cipher:
  34. Master_SSL_Key:
  35. Seconds_Behind_Master:NULL
  36. Master_SSL_Verify_Server_Cert:No
  37. Last_IO_Errno:0
  38. Last_IO_Error:
  39. Last_SQL_Errno:1594
  40. Last_SQL_Error:Relaylogreadfailure:Couldnotparserelaylogevententry.Thepossiblereasonsare:themaster’sbinarylogiscorrupted(youcancheckthisbyrunning‘mysqlbinlog’onthebinarylog),theslave’srelaylogiscorrupted(youcancheckthisbyrunning‘mysqlbinlog’ontherelaylog),anetworkproblem,orabuginthemaster’sorslave’sMySQLcode.Ifyouwanttocheckthemaster’sbinarylogorslave’srelaylog,youwillbeabletoknowtheirnamesbyissuing‘SHOWSLAVESTATUS’onthisslave.
  41. Replicate_Ignore_Server_Ids:
  42. Master_Server_Id:1016
  43. Master_UUID:7b6b6934-b981-11e3-bc82-c81f66de76ac
  44. Master_Info_File:/data/mysql/data/master.info
  45. SQL_Delay:0
  46. SQL_Remaining_Delay:NULL
  47. Slave_SQL_Running_State:
  48. Master_Retry_Count:86400
  49. Master_Bind:
  50. Last_IO_Error_Timestamp:
  51. Last_SQL_Error_Timestamp:14072510:54:50
  52. Master_SSL_Crl:
  53. Master_SSL_Crlpath:
  54. Retrieved_Gtid_Set:
  55. Executed_Gtid_Set:
  56. Auto_Position:0
  57. 1rowinset(0.00sec)
  58. [root@localhostdata]#mysqlbinloglocalhost-relay-bin.000137>a.txt
  59. ERROR:ErrorinLog_event::read_log_event():‘readerror’,data_len:7736,event_type:31
  60. ERROR:Couldnotreadentryatoffset215681738:Errorinlogformatorreaderror.
  61. WARNING:TherangeofprintedeventsendswitharoweventoratablemapeventthatdoesnothavetheSTMT_END_Fflagset.Thismightbebecausethelaststatementwasnotfullywrittentothelog,orbecauseyouareusinga-stop-positionor-stop-datetimethatreferstoaneventinthemiddleofastatement.Theevent(s)fromthepartialstatementhavenotbeenwrittentooutput.

总结:这两个错误的导致的原因是机房掉电,也就是没有crash safe.

相关广告
  • mysql数据库 slave复制异常问题解决办法 mysql数据库 slave复制异常问题解决办法 mysql数据库 slave复制异常问题解决办法
相关阅读

mysql数据库 slave复制异常问题解决办法

2019/10/10 17:32:44 | 谷歌SEO算法 | 手机网站制作