通过MySQL连接查看binlog
云淡风惊
2022-08-14 PM
℃
0条
1. 通过show master status来查看当前写入的binlog的位点
file表示下一个binlog的bytes内容即将写入的文件名
position表示下一个binlog的bytes内容写入到file中的位点的起点(byte字节数)
Binlog_Do_DB表示需要记录binlog的库名列表,也就是白名单
Binlog_Ignore_DB表示需要忽略的binlog的库名列表,也就是黑名单
Executed_Gtid_Set表示本库中已经执行完的全局事务的id集合
-
show master status;
File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | |
---|
mysql-bin.007419 | 351354797 | | | c63372d9-2d61-11ea-974d-6c92bf5ca3fe:1-2295638934 | |
2. binlog列表,表示本地保存的binlog及其大小(byte字节数)
show binary logs;
Log_name | File_size | |
---|
mysql-bin.007398 | 524288984 | |
mysql-bin.007399 | 479166257 | |
mysql-bin.007400 | 150546852 | |
mysql-bin.007401 | 524289051 | |
mysql-bin.007402 | 524288748 | |
3. 预览binlog内容,命令内容中
in后面为binlog的文件名
from为byte数偏移量
limit为需要读取的binlog的event数量
event内容中
pos为本event的byte在binlog文件中的偏移量
end_log_pos为下一个event的偏移量
event_type为event类型
server_id为MySQL的id
info为binlog内容
-
show binlog events in 'mysql-bin.007415' from 413473280 limit 4;
Log_name | Pos | Event_type | Server_id | End_log_pos | Info | |
---|
mysql-bin.007415 | 413473280 | Xid | 1432166402 | 413473311 | COMMIT / xid=9569995796 / | |
mysql-bin.007415 | 413473311 | Gtid | 1432166402 | 413473376 | SET @@SESSION.GTID_NEXT= 'xxx-xxx-xx-x-xx:xx' | |
mysql-bin.007415 | 413473376 | Query | 1432166402 | 413473448 | BEGIN | |
mysql-bin.007415 | 413473448 | Table_map | 1432166402 | 413473512 | table_id: 767016795 (xxx.xxx) | |