从库延迟:
Seconds_Behind_Master: 380
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Exec_Master_Log_Pos: 709257579
Relay_Log_Space: 472602209
通过show slave status发现Exec_Master_Log_Pos 一直不变,Relay_Log_Space在变化。
猜想可能是由于Master上执行了某些大的操作,导致产生了大量的binlog,引起了slave hang住。
mysql> show open tables where In_use=1;
+----------+----------------------------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+----------------------------+--------+-------------+
| kpi_test | tf_launch_times | 1 | 0|
+----------+----------------------------+--------+-------------+
1 row in set (0.00 sec)
mysql> show create table tf_launch_times\G
*************************** 1. row ***************************
Table: tf_launch_times
Create Table: CREATE TABLE `tf_launch_times` (
`stat_date` date NOT NULL COMMENT '',
`stat_hour` varchar(8) DEFAULT NULL,
`launch_times` int(20) DEFAULT NULL COMMENT '',
`channel_id` int(11) unsigned DEFAULT '0' COMMENT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
mysql> select count(1) from tf_launch_times;
+----------+
| count(1) |
+----------+
| 3297957 |
+----------+
1 row in set (0.27 sec)
解析master上的binlog,果然是在对这个表做update。
于是先stop slave。给这个表加上索引。等待slave慢慢恢复正常。
Seconds_Behind_Master: 380
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Exec_Master_Log_Pos: 709257579
Relay_Log_Space: 472602209
通过show slave status发现Exec_Master_Log_Pos 一直不变,Relay_Log_Space在变化。
猜想可能是由于Master上执行了某些大的操作,导致产生了大量的binlog,引起了slave hang住。
mysql> show open tables where In_use=1;
+----------+----------------------------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+----------------------------+--------+-------------+
| kpi_test | tf_launch_times | 1 | 0|
+----------+----------------------------+--------+-------------+
1 row in set (0.00 sec)
mysql> show create table tf_launch_times\G
*************************** 1. row ***************************
Table: tf_launch_times
Create Table: CREATE TABLE `tf_launch_times` (
`stat_date` date NOT NULL COMMENT '',
`stat_hour` varchar(8) DEFAULT NULL,
`launch_times` int(20) DEFAULT NULL COMMENT '',
`channel_id` int(11) unsigned DEFAULT '0' COMMENT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
没有主键,没有索引,这样的表是怎么上了生产环境呢?
mysql> select count(1) from tf_launch_times;
+----------+
| count(1) |
+----------+
| 3297957 |
+----------+
1 row in set (0.27 sec)
解析master上的binlog,果然是在对这个表做update。
于是先stop slave。给这个表加上索引。等待slave慢慢恢复正常。