Mysql数据库复制延时分析
2012-07-21 15:35:15   来源:我爱运维网   评论:0 点击:

现象:Mysql主从复制,出现延时报警。排查分析:延迟期间mysql备库执行次数从10000降到了1。从库在3:10-4:10之间基本没有执行什么sql, bin...
现象:Mysql主从复制,出现延时报警。
排查分析:

延迟期间
mysql备库执行次数从10000降到了1
 
从库在3:10-4:10之间基本没有执行什么sql, binlog010177:
-rw-rw---- 1 mysql mysql 134218050 Jul 18 04:17 mysql-bin.010178
-rw-rw---- 1 mysql mysql 134217813 Jul 18 04:15 mysql-bin.010177
-rw-rw---- 1 mysql mysql 134218004 Jul 18 03:05 mysql-bin.010176
 
Dump binlog并且分析,排除exec_time=[0-9](基本不延迟的sql:
grep exec_time binlog_010177.txt|egrep -v "exec_time=[0-9]\s" |more
 
#120718  3:05:11 server id 41  end_log_pos 4204919      Query   thread_id=72265543      exec_time=4294967295    error_code=0
….
#120718  3:09:58 server id 41  end_log_pos 49897358     Query   thread_id=72059376      exec_time=4294967295    error_code=0
#120718  3:10:01 server id 41  end_log_pos 51693592     Query   thread_id=72265543      exec_time=3863  error_code=0 =>突然出现延迟
#120718  3:10:01 server id 41  end_log_pos 51693804     Query   thread_id=72265543      exec_time=3863  error_code=0
#120718  3:10:01 server id 41  end_log_pos 51693904     Query   thread_id=72273535      exec_time=3863  error_code=0
#120718  3:10:01 server id 41  end_log_pos 51694116     Query   thread_id=72273535      exec_time=3863  error_code=0
 
Mysql有大量读操作:
                Data_W Data_R  Log_W  D_fync L_fync Curr_Lock Lock_tim PageData PageFree PageFlush DiskRead Dblwr_w PageRe PageWri
07-18 03:09:23    274      0    251     13    11        0        0     19094M        3M       42        0        1       0     21
07-18 03:09:33    454      0    228     20    12        0        0     19094M        3M      440        0        3       0    220
07-18 03:09:43    470      0    244     27    12        0        0     19094M        3M      440        0        3       0    220
07-18 03:09:53    461      0    234     19    11        0        0     19094M        3M      442        0        3       0    221
07-18 03:10:03   5346    263   5119     22    11        0        0     19098M        0M      442      136        3     238    221
07-18 03:10:13     22  10654      0      4     1        0        0     19098M        0M       40     2234        1   10679     20
07-18 03:10:23     23   4197      1      4     2        0        0     19098M        0M       40     2631        1    4197     20
07-18 03:10:33    545   8461      0     26     4        0        0     19098M        0M     1060     1231        6    8461    530
07-18 03:10:43      0  12734      0      0     0        0        0     19098M        0M        0        1        0   12734      0
07-18 03:10:53      0  11204      0      0     0        0        0     19098M        0M        0       72        0   11204      0
07-18 03:11:03      0  12151      0      0     0        0        0     19098M        0M        0      980        0   12151      0
07-18 03:11:13      0  11876      0      0     0        0        0     19098M        0M        0      311        0   11876      0
07-18 03:11:23      0      0      0      0     0        0        0     19098M        0M        0        0        0       0      0
 
磁盘IO那段时间很高:
Mysql数据库复制延时分析
 
机器文件缓存出现过突然的释放:
Mysql数据库复制延时分析
 
详细分析:
 
1.       肯定是有某个大的操作,导致缓存被flush
2.       Slow query log可以看到大量的全表nocache
3.       突然延迟说明之前的恢复操作是被锁住,而不是执行缓慢
4.       怀疑是备份程序导致,可以从时间上验证是吻合的
[root@MYSQLDB2]# ls -altd /home/mysql/backup/DB2/3306
drwxrwxr-x 3 mysql mysql 4096 Jul 18 03:10 /home/mysql/backup/DB2/3306
5.       为何会锁: 数据库还是有很多表是myisam引擎,innobackup会上锁, 之前的备份都出现过同样的问题:
mysql> select TABLE_SCHEMA,count(*) from tables  where engine='MyISAM' and table_schema!='mysql' group by table_schema;
+--------------------+----------+
| TABLE_SCHEMA       | count(*) |
+--------------------+----------+
| gongyuan           |        2 |
| information_schema |        9 |
| 5iops_ad          |       23 |
| 5iops_comment_log     |      379 |
| srv_gongyuan       |       15 |
| 5iops_upload       |        1 |
+--------------------+----------+
6 rows in set (0.20 sec)
 
Todo:
1.       全网检查myisam引擎的表
2.       发现long_query_time还是有机器没有设置,需要全网检查

相关热词搜索:Mysql 数据库 复制

上一篇:Redis Bug:maxmemory+evicting policy+slaves=death
下一篇:最后一页

分享到: 收藏
评论排行