SQL_Remaining_Delay这个参数

 

在部署一个只读实例,测试的时候,设置了延时6个小时,启动起来看到情况如下,show slave status\G中关于延时相关的值:

        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 123
                  Master_UUID: xxxxxx-xxxx-11eb-9a26-xxxxxxxxx
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 22600
          SQL_Remaining_Delay: 4110
      Slave_SQL_Running_State: Waiting until MASTER_DELAY seconds after master executed event
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl:
			   

 

SQL_Delay这个值是准确的,6个小时是22600,但是Seconds_Behind_Master这个参数确实0,并不像我预料中的是22600,理论上,设置好延时复制后,Seconds_Behind_Master的值不应该是0而是延迟6个小时的值。

 

另外发现了一个SQL_Remaining_Delay这个的值在变化,是抖动式的,一会高一会低,但是总体是往下走的下降趋势。查看了下官网文章:https://dev.mysql.com/doc/refman/5.7/en/replication-delayed.html,里面有如下解释

  • SQL_Delay: A nonnegative integer indicating the number of seconds that the replica must lag the source.

  • SQL_Remaining_Delay: When Slave_SQL_Running_State is Waiting until MASTER_DELAY seconds after master executed event, this field contains an integer indicating the number of seconds left of the delay. At other times, this field is NULL.

  • Slave_SQL_Running_State: A string indicating the state of the SQL thread (analogous to Slave_IO_State). The value is identical to the State value of the SQL thread as displayed by SHOW PROCESSLIST.

 

总算明白了,就是在启动的时候,当前部署的只读库的最新数据离主库小于6小时,那么这个SQL_Remaining_Delay:当 Slave_SQL_Running_State 等待,直到MASTER_DELAY秒后,Master执行的事件,此字段包含一个整数,表示有多少秒左右的延迟。在其他时候,这个字段是0。

 

那么这种时候,只有等只读实例慢慢恢复,当SQL_Remaining_Delay慢慢变小到0的时候,Seconds_Behind_Master就会从0变成22600的。

 

过了3分小时候,再进来看slave状态,就变成了我们想要的那个样子:

Seconds_Behind_Master: 22602
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 123
                  Master_UUID: xxxxxx-xxxx-11eb-9a26-xxxxxxxxx
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 22600
          SQL_Remaining_Delay: 2
      Slave_SQL_Running_State: Waiting until MASTER_DELAY seconds after master executed event
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 			   

 


版权声明:本文为csdnhsh原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。