某些时候需要判断binlog中是否有大事物的存在,比如在解决master-slave延迟高的情况下。
工具下载地址:http://pan.baidu.com/s/1jHIWUN0
表结构
< yoon]> show create table aG *************************** 1. row *************************** Table: a Create Table: CREATE TABLE `a` ( `id` int(11) NOT NULL AUTO_INCREMENT, `order_id` bigint(20) DEFAULT NULL, `name` varchar(49) DEFAULT NULL, `sexy` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `idx_order_id_name` (`name`,`order_id`) ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4
创建一个事务
< yoon]> show variables like 'autocommit'; < yoon]> set autocommit = 0; < yoon]> insert into a (order_id,name,sexy) values (6,'CCC','N'); < yoon]> insert into a (order_id,name,sexy) values (6,'CCC','N'); < yoon]> insert into a (order_id,name,sexy) values (6,'CCC','N'); < yoon]> set autocommit = 1;
infobin
[root@127-0-0-1 u01]# ./infobin [binlogfile]:binlog file! [piece]:how many piece will split,is a Highly balanced histogram, find which time generate biggest binlog.(must:piece<2000000) [bigtrxsize](bytes):larger than this size trx will view.(must:trx>256(bytes)) [bigtrxtime](sec):larger than this sec trx will view.(must:>0(sec)) [[-t]]:if [-t] no detail is print out,the result will small [[-force]]:force analyze if unkown error check!! 【piece】:分片参数,比如1G的binlog分为10片那么1片就是100M左右 【bigtrxsize】: 【bigtrxtime】:时间,单位秒
使用infobin来查看binlog日志,10代表分10片,2000000代表2MB,1代表1秒
[root@127-0-0-1 u01]# ./infobin mysql-bin.000012 10 2000000 1 -t > hank.log
查看hank.log日志
[root@127-0-0-1 u01]# cat hank.log Check is Little_endian [Author]: gaopeng [QQ]:22389860 [blog]:http://blog.itpub.net/7728585/ Warning: This tool only Little_endian platform! Little_endian check ok!!! -------------Now begin-------------- Check Mysql Version is:5.6.37-82.2-log Check Mysql binlog format ver is:V4 Warning:Check This binlog is not closed! Check This binlog total size:43717820(bytes) Note:load data infile not check! -------------Total now-------------- Trx total[counts]:4931 Event total[counts]:30982 Max trx event size:648532(bytes) Pos:14284738[0XD9F7C2] Avg binlog size(/sec):258.668(bytes)[0.253(kb)] Avg binlog size(/min):15520.109(bytes)[15.156(kb)] --Piece view: (1)Time:1587830111-1587830111(0(s)) piece:4371782(bytes)[4269.318(kb)] (2)Time:1587830111-1587830112(1(s)) piece:4371782(bytes)[4269.318(kb)] (3)Time:1587830112-1587830112(0(s)) piece:4371782(bytes)[4269.318(kb)] (4)Time:1587830112-1587916501(86389(s)) piece:4371782(bytes)[4269.318(kb)] (5)Time:1587916501-1587916503(2(s)) piece:4371782(bytes)[4269.318(kb)] (6)Time:1587916503-1587916504(1(s)) piece:4371782(bytes)[4269.318(kb)] (7)Time:1587916504-1587916504(0(s)) piece:4371782(bytes)[4269.318(kb)] (8)Time:1587916504-1587916504(0(s)) piece:4371782(bytes)[4269.318(kb)] (9)Time:1587916504-1587916505(1(s)) piece:4371782(bytes)[4269.318(kb)] (10)Time:1587916505-1587999122(82617(s)) piece:4371782(bytes)[4269.318(kb)] --Large than 2000000(bytes) trx: No trx find! --Large than 1(secs) trx: (存在事务大于1S的,第十个是刚测试insert的事务语句) (1)Trx_sec:59(sec) trx_begin_time:[20200427 12:18:23(CST)] trx_end_time:[20200427 12:19:22(CST)] trx_begin_pos:43709435 trx_end_pos:43709810 query_exe_time:0 (2)Trx_sec:118(sec) trx_begin_time:[20200427 12:22:41(CST)] trx_end_time:[20200427 12:24:39(CST)] trx_begin_pos:43709858 trx_end_pos:43710500 query_exe_time:0 (3)Trx_sec:41(sec) trx_begin_time:[20200427 12:24:11(CST)] trx_end_time:[20200427 12:24:52(CST)] trx_begin_pos:43710548 trx_end_pos:43710923 query_exe_time:0 (4)Trx_sec:141(sec) trx_begin_time:[20200427 12:36:11(CST)] trx_end_time:[20200427 12:38:32(CST)] trx_begin_pos:43711819 trx_end_pos:43712196 query_exe_time:0 (5)Trx_sec:114(sec) trx_begin_time:[20200427 12:36:45(CST)] trx_end_time:[20200427 12:38:39(CST)] trx_begin_pos:43712244 trx_end_pos:43713159 query_exe_time:0 (6)Trx_sec:27(sec) trx_begin_time:[20200427 16:40:16(CST)] trx_end_time:[20200427 16:40:43(CST)] trx_begin_pos:43714610 trx_end_pos:43715000 query_exe_time:0 (7)Trx_sec:3(sec) trx_begin_time:[20200427 16:41:42(CST)] trx_end_time:[20200427 16:41:45(CST)] trx_begin_pos:43715048 trx_end_pos:43715438 query_exe_time:0 (8)Trx_sec:67(sec) trx_begin_time:[20200427 16:42:31(CST)] trx_end_time:[20200427 16:43:38(CST)] trx_begin_pos:43715486 trx_end_pos:43715865 query_exe_time:0 (9)Trx_sec:1636(sec) trx_begin_time:[20200427 16:16:29(CST)] trx_end_time:[20200427 16:43:45(CST)] trx_begin_pos:43715913 trx_end_pos:43716776 query_exe_time:0 (10)Trx_sec:21(sec) trx_begin_time:[20200427 22:51:41(CST)] trx_end_time:[20200427 22:52:02(CST)] trx_begin_pos:43716976 trx_end_pos:43717820 query_exe_time:0 --Every Table binlog size(bytes) and times: Note:size unit is bytes ---(1)Current Table:yoon.a:: Insert:binlog size(216(Bytes)) times(4) Update:binlog size(0(Bytes)) times(0) Delete:binlog size(0(Bytes)) times(0) Total:binlog size(216(Bytes)) times(4) ---(2)Current Table:yoon.mp_message_202004:: Insert:binlog size(1934(Bytes)) times(25) Update:binlog size(320(Bytes)) times(4) Delete:binlog size(0(Bytes)) times(0) Total:binlog size(2254(Bytes)) times(29) ---(3)Current Table:slow_query_log.global_query_review_history:: Insert:binlog size(4942881(Bytes)) times(2653) Update:binlog size(43504(Bytes)) times(57) Delete:binlog size(0(Bytes)) times(0) Total:binlog size(4986385(Bytes)) times(2710) ---(4)Current Table:slow_query_log.global_query_review:: Insert:binlog size(272230(Bytes)) times(163) Update:binlog size(13125484(Bytes)) times(2033) Delete:binlog size(0(Bytes)) times(0) Total:binlog size(13397714(Bytes)) times(2196) ---Total binlog dml event size:18386569(Bytes) times(4939)