【Mysql】mysql主键的缺少导致备库hang-创新互联

最近线上频繁的出现slave延时的情况,经排查发现为用户在删除数据的时候,由于表主键的缺少,同时删除条件没有索引,或或者删除的条件过滤性极差,导致slave出现hang住,严重的影响了生产环境的稳定性,也希望通过这篇博客,来加深主键在innodb引擎中的重要性,希望用户在使用RDS,设计自己的表的时候,一定要为表加上主键,主键可以认为是innodb存储引擎的生命,下面我们就来分析一下这个案例(本案例的生产环境的binlog为row模式,对于myisam存储引擎也有同样的问题):
  1. (1).现象slave:
  1. mysql> show slave status\G;
  2. *************************** 1. row ***************************
  3. Slave_IO_State: Waiting for master to send event
  4. Master_Host: xxx.xx.xx.xx
  5. Master_User: replicator
  6. Master_Port: 3006
  7. Connect_Retry: 60
  8. Master_Log_File: mysql-bin.000006
  9. Read_Master_Log_Pos: 47465657
  10. Relay_Log_File: slave-relay.100383
  11. Relay_Log_Pos: 251
  12. Relay_Master_Log_File: mysql-bin.000006
  13. Slave_IO_Running: Yes
  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: 18057461
  25. Relay_Log_Space: 29409335
  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: 1339
  36. Master_SSL_Verify_Server_Cert: No
  37. Last_IO_Errno: 0
  38. Last_IO_Error:
  39. Last_SQL_Errno: 0
  40. Last_SQL_Error:
  41. slave的Seconds_Behind_Master一直在增加,slave出现hang住。

当前题目:【Mysql】mysql主键的缺少导致备库hang-创新互联
本文地址:http://myzitong.com/article/dpedgo.html