mysqlbinlog日志查看
mysqlbinlog --no-defaults --database=etl_test_1210 --base64-output=decode-rows -v --start-datetime='2021-12-03 09:00:00' --stop-datetime='2021-12-03 10:27:00' mysql-bin.001019
先查看binlog是否开启以及位置
# 是否启用binlog日志
show variables like 'log_bin';
# 日志保存时长
show variables like '%expire_logs_days%';
# 查看当前服务器使用的binlog文件及大小
show binary logs;
# 查看 binlog 内容
show binlog events;
# 查看binlog的目录
show global variables like "%log_bin%";
到mysql主机上的binlog的目录下查找binlog文件,因为是二进制的所以要使用mysqlbinlog命令打开
mysqlbinlog --no-defaults --database=etl_test_1210 --base64-output=decode-rows -v --start-datetime='2021-12-03 09:00:00' --stop-datetime='2021-12-03 10:27:00' mysql-bin.001019
可以根据时间或文件位置来选择性的打开查看
日志分析
通过MysqlBinlog指令查看具体的mysql日志,如下:
///
SET TIMESTAMP=1350355892/*!*/;
BEGIN
/*!*/;
# at 1643330
#121016 10:51:32 server id 1 end_log_pos 1643885 Query thread_id=272571 exec_time=0 error_code=0
SET TIMESTAMP=1350355892/*!*/;
Insert into T_test….)
/*!*/;
# at 1643885
#121016 10:51:32 server id 1 end_log_pos 1643912 Xid = 0
COMMIT/*!*/;
///
1.开始事物的时间:
SET TIMESTAMP=1350355892/*!*/;
BEGIN
2.sqlevent起点
#at 1643330 :为事件的起点,是以1643330字节开始。
3.sqlevent 发生的时间点
#121016 10:51:32:是事件发生的时间,
4.serverId
server id 1 :为master 的serverId
5.sqlevent终点及花费时间,错误码
end_log_pos 1643885:为事件的终点,是以1643885 字节结束。
execTime 0: 花费的时间
error_code=0:错误码
Xid:事件指示提交的XA事务全局分布式id和InnoDB内部维护的trx_id不同
更多推荐
所有评论(0)