现象:
slave 上 Slave_IO_Running,Slave_SQL_Running都正常,Seconds_Behind_Master持续增长,但Exec_Master_Log_Pos持续不改变。
mysql> pager grep -i -E 'Running|Seconds|Slave|master_log_pos|Master_log_file|Master_Host|Master_Port|Relay_Log|Errno';
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Log_File: mysql-bin.000031
Read_Master_Log_Pos: 649395134
Relay_Log_File: mysql01-relay-bin.000092
Relay_Log_Pos: 112042172
Relay_Master_Log_File: mysql-bin.000031
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Exec_Master_Log_Pos: 613518358
Relay_Log_Space: 649394045
Seconds_Behind_Master: 17557
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Log_File: mysql-bin.000031
Read_Master_Log_Pos: 650107949
Relay_Log_File: mysql01-relay-bin.000092
Relay_Log_Pos: 112042172
Relay_Master_Log_File: mysql-bin.000031
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Exec_Master_Log_Pos: 613518358
Relay_Log_Space: 650106860
Seconds_Behind_Master: 19560
分析过程:
根据show slave status中得到的中继日志文件与位置点分析relaylog
Relay_Log_File: mysql01-relay-bin.000092
Relay_Log_Pos: 112042172
mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS mysql01-relay-bin.000092 --start-position=112042172|more
这个位置点开始是对一个百万级表的update操作,而这个update操作是个全表扫描。表上没主键和索引。
解决办法:
分析了update语句后,给表加上相关的索引,Exec_Master_Log_Pos开始变化,Seconds_Behind_Master也在逐渐减小。
slave 上 Slave_IO_Running,Slave_SQL_Running都正常,Seconds_Behind_Master持续增长,但Exec_Master_Log_Pos持续不改变。
mysql> pager grep -i -E 'Running|Seconds|Slave|master_log_pos|Master_log_file|Master_Host|Master_Port|Relay_Log|Errno';
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Log_File: mysql-bin.000031
Read_Master_Log_Pos: 649395134
Relay_Log_File: mysql01-relay-bin.000092
Relay_Log_Pos: 112042172
Relay_Master_Log_File: mysql-bin.000031
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Exec_Master_Log_Pos: 613518358
Relay_Log_Space: 649394045
Seconds_Behind_Master: 17557
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Log_File: mysql-bin.000031
Read_Master_Log_Pos: 650107949
Relay_Log_File: mysql01-relay-bin.000092
Relay_Log_Pos: 112042172
Relay_Master_Log_File: mysql-bin.000031
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Exec_Master_Log_Pos: 613518358
Relay_Log_Space: 650106860
Seconds_Behind_Master: 19560
分析过程:
根据show slave status中得到的中继日志文件与位置点分析relaylog
Relay_Log_File: mysql01-relay-bin.000092
Relay_Log_Pos: 112042172
mysqlbinlog --no-defaults -v -v --base64-output=DECODE-ROWS mysql01-relay-bin.000092 --start-position=112042172|more
这个位置点开始是对一个百万级表的update操作,而这个update操作是个全表扫描。表上没主键和索引。
解决办法:
分析了update语句后,给表加上相关的索引,Exec_Master_Log_Pos开始变化,Seconds_Behind_Master也在逐渐减小。