mysql复制卡住

q1qsirdb  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(421)

我设置了从主服务器到从服务器的mysql复制。”show slave status\g“显示从机状态\g”显示的秒数比主机持续增加。下面是从最旧(顶部)到最新(底部)的三个连续结果。有人知道怎么回事吗?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
1

  1. mysql> SHOW SLAVE STATUS\G
  2. ***************************1. row***************************
  3. Slave_IO_State: Queueing master event to the relay log
  4. Master_Host: <excluding>
  5. Master_User: <excluding>
  6. Master_Port: 3306
  7. Connect_Retry: 60
  8. Master_Log_File: mysql-bin.002723
  9. Read_Master_Log_Pos: 893947806
  10. Relay_Log_File: design-hotels-database-relay-bin.000002
  11. Relay_Log_Pos: 7692403
  12. Relay_Master_Log_File: mysql-bin.002723
  13. Slave_IO_Running: Yes
  14. Slave_SQL_Running: Yes
  15. Replicate_Do_DB:
  16. Replicate_Ignore_DB: starwood_sop,starwood_blp
  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: 192464416
  25. Relay_Log_Space: 709176017
  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: 76613
  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. Replicate_Ignore_Server_Ids:
  42. Master_Server_Id: 3
  43. Master_UUID:
  44. Master_Info_File: /var/lib/mysql/master.info
  45. SQL_Delay: 0
  46. SQL_Remaining_Delay: NULL
  47. Slave_SQL_Running_State: Reading event from the relay log
  48. Master_Retry_Count: 86400
  49. Master_Bind:
  50. Last_IO_Error_Timestamp:
  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. Replicate_Rewrite_DB:
  58. Channel_Name:
  59. Master_TLS_Version:
  60. 1 row in set (0.04 sec)

2

  1. mysql> SHOW SLAVE STATUS\G
  2. ***************************1. row***************************
  3. Slave_IO_State: Queueing master event to the relay log
  4. Master_Host: <excluding>
  5. Master_User: <excluding>
  6. Master_Port: 3306
  7. Connect_Retry: 60
  8. Master_Log_File: mysql-bin.002723
  9. Read_Master_Log_Pos: 908310158
  10. Relay_Log_File: design-hotels-database-relay-bin.000002
  11. Relay_Log_Pos: 7906291
  12. Relay_Master_Log_File: mysql-bin.002723
  13. Slave_IO_Running: Yes
  14. Slave_SQL_Running: Yes
  15. Replicate_Do_DB:
  16. Replicate_Ignore_DB: starwood_sop,starwood_blp
  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: 192678304
  25. Relay_Log_Space: 723538369
  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: 76698
  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. Replicate_Ignore_Server_Ids:
  42. Master_Server_Id: 3
  43. Master_UUID:
  44. Master_Info_File: /var/lib/mysql/master.info
  45. SQL_Delay: 0
  46. SQL_Remaining_Delay: NULL
  47. Slave_SQL_Running_State: Reading event from the relay log
  48. Master_Retry_Count: 86400
  49. Master_Bind:
  50. Last_IO_Error_Timestamp:
  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. Replicate_Rewrite_DB:
  58. Channel_Name:
  59. Master_TLS_Version:
  60. 1 row in set (0.06 sec)

  1. mysql> SHOW SLAVE STATUS\G
  2. ***************************1. row***************************
  3. Slave_IO_State: Queueing master event to the relay log
  4. Master_Host: <excluding>
  5. Master_User: <excluding>
  6. Master_Port: 3306
  7. Connect_Retry: 60
  8. Master_Log_File: mysql-bin.002723
  9. Read_Master_Log_Pos: 945765663
  10. Relay_Log_File: design-hotels-database-relay-bin.000002
  11. Relay_Log_Pos: 8389913
  12. Relay_Master_Log_File: mysql-bin.002723
  13. Slave_IO_Running: Yes
  14. Slave_SQL_Running: Yes
  15. Replicate_Do_DB:
  16. Replicate_Ignore_DB: starwood_sop,starwood_blp
  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: 193161926
  25. Relay_Log_Space: 760993874
  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: 76870
  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. Replicate_Ignore_Server_Ids:
  42. Master_Server_Id: 3
  43. Master_UUID:
  44. Master_Info_File: /var/lib/mysql/master.info
  45. SQL_Delay: 0
  46. SQL_Remaining_Delay: NULL
  47. Slave_SQL_Running_State: Reading event from the relay log
  48. Master_Retry_Count: 86400
  49. Master_Bind:
  50. Last_IO_Error_Timestamp:
  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. Replicate_Rewrite_DB:
  58. Channel_Name:
  59. Master_TLS_Version:
  60. 1 row in set (0.04 sec)
uurity8g

uurity8g1#

嗯,那个 Exec_Master_Log_Pos 也在增加,这表明sql线程实际上正在工作并应用更改。只是速度不够快,跟不上传入的日志,这表明 Read_Master_Log_Pos ```
Exec-pos Read-pos
1: 192464416 893947806
2: 192678304 (+213,888) 908310158 (+14,362,352
3: 193161926 (+483,622) 945765663 (+37,455,505)

  1. 因此,传入日志(read pos)的到达速率比复制能够在从属示例上执行更改的速率高出许多倍。
  2. 复制滞后是一个复杂的问题,其原因是多方面的。有许多配置设置可用于帮助提高从机的吞吐量。您没有描述任何有关当前配置、数据库更改的性质或正在更改的表的信息,因此我无法提供真正有根据的建议。但以下是我通常做的一些典型改变:

innodb_buffer_pool_size = # depends on server RAM and other factors
innodb_log_file_size = 1G # or more
innodb_flush_log_at_trx_commit = 2
master_info_repository = TABLE
relay_log_info_repository = TABLE
relay_log_recovery = ON
sync_master_info = 0
binlog_format = ROW # make sure all tables have PRIMARY KEY constraints

  1. 有关这些选项的详细信息,请参阅mysql文档。
  2. 即使使用了所有这些调优技巧,最终您也可能会遇到一个限制,即从线程能够在单个线程中重放在主线程的多个线程中创建的更改。
  3. 您可能可以使用多线程从机,但这并不像听起来那么简单,因此在尝试此操作之前,您需要阅读更多关于它的内容。
  4. 即使使用调优和多线程从属,也有可能达到硬件的极限。它根本无法足够快地处理这些变化。您可以将硬件升级到更快的cpu和更快的存储。
  5. 另一个选择是降低主数据库的更改率。要么在主服务器上限制更改,要么部署多个主服务器及其各自的从属服务器,并在多个主服务器上平衡更改。
展开查看全部

相关问题