線上處理問題的時候常常遇到業務說寫入了可是數據不對,這種狀況八成是業務改了以後又改過來了。可是咱們須要證據,下面咱們就說說簡單的binlog分析mysql
工具:mysqlbinloggit
#-vvv顯示明文sql內容方便查閱
#start-datetime分析開始時間
#stop-datatime分析結束時間
#-d數據庫名稱
#mysql-bin.000001 二進制文件
$mysqlbinlog -vvv --start-datetime=
'2018-11-15 18:47:00'
--stop-datetime=
'2018-11-15 18:59:01'
-uxxxxx --socket=
/export/data/mysql/tmp/mysql
.socket --port=3358 -d xxxxx mysql-bin.000001 > 1.txt
#經過執行以上命令就能夠獲取這個時間段裏面的binlog信息
|
如下是部分解析出來的內容,文件裏面有時間戳,能夠根據時間戳就判斷某個操做是否執行sql
#
at
590290541
#181115 18:47:00 server id 23083726 end_log_pos 590290606 CRC32 0x644652ac GTID last_committed=210987 sequence_number=210988 rbr_only=yes
/*!50718
SET
TRANSACTION
ISOLATION
LEVEL
READ
COMMITTED
*//*!*/;
SET
@@SESSION.GTID_NEXT=
'd2eabe2a-d5cb-11e8-a72a-fa169c5fc76e:191960'
/*!*/;
#
at
590290606
#181115 18:47:00 server id 23083726 end_log_pos 590290695 CRC32 0xcdd93a59 Query thread_id=95124 exec_time=0 error_code=0
SET
TIMESTAMP
=1542278820/*!*/;
SET
@@session.pseudo_thread_id=95124/*!*/;
SET
@@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET
@@session.sql_mode=1073741824/*!*/;
SET
@@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb4 *//*!*/;
SET
@@session.character_set_client=45,@@session.collation_connection=45,@@session.collation_server=45/*!*/;
SET
@@session.time_zone=
'SYSTEM'
/*!*/;
SET
@@session.lc_time_names=0/*!*/;
SET
@@session.collation_database=
DEFAULT
/*!*/;
BEGIN
/*!*/;
#
at
590290695
#181115 18:47:00 server id 23083726 end_log_pos 590291436 CRC32 0xf28f1bd8 Rows_query
#
insert
into
xxxxx(do_no, group_key, wave_strategy, auto_able, expect_pick_time, partitions, loc_code_list, priority, wms_sku_list, merge_no, weight, volume, area_id, area_name, latitude, longitude, wh_id, tenant_id, uuid, create_time, wh_name, wh_code, expect_arrive_starttime, expect_arrive_endtime, do_create_date, genera_source, extend_data)
values
(
'65000372273101'
,
'sell_default'
, 0, 1,
'2018-11-15 19:18:00'
,
null
,
'[\"36518\",\"40001\"]'
, 5,
'[1007116,1002291,1011345]'
,
null
, 4.580, 14178.416, 200030,
'褐石園區'
,
'40.016893'
,
'116.322341'
, 131231, 1,
'65000372273101-1'
, now(),
'五彩城店'
,
'WCC'
,
'2018-11-15 19:30:00'
,
'2018-11-15 20:15:00'
,
'2018-11-15 18:47:00'
,
'AI'
,
'{\"workFood\":\"1\"}'
)
#
at
590291436
#181115 18:47:00 server id 23083726 end_log_pos 590291571 CRC32 0x3a2c02ea Table_map: `xxxxxx`.`wms_ai_do` mapped
to
number 262
#
at
590291571
#181115 18:47:00 server id 23083726 end_log_pos 590291874 CRC32 0x8f14b7cb Write_rows:
table
id 262 flags: STMT_END_F
|