前言
MySQL同步功能由3个线程(master上1个,slave上2个)来实现,简单的说就是:master发送日志一个,slave接收日志一个,slave运行日志一个。
主从延迟判断的方法,通常有两种方法:Seconds_Behind_Master和pt-heartbeat
1.Seconds_Behind_Master
通过监控show slave status\G命令输出的Seconds_Behind_Master参数的值来判断,是否有发生主从延时。
mysql>show slave status\G;*************************** 1. row ***************************Slave_IO_State: Waitingfor master to send eventMaster_Host:
Master_User:
Master_Port:3306Connect_Retry:60Master_Log_File: mysql-bin.000022Read_Master_Log_Pos:879720441Relay_Log_File:***-relay-bin.000011Relay_Log_Pos:250520472Relay_Master_Log_File: mysql-bin.000022Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: retail
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table: