解析MYSQL BINLOG二進位制格式(8)--GTID_LOG_EVENT/ANONYMOUS_GTID_LOG_EVENT及其他
原創:轉載請說明出處謝謝!
上接
http://blog.itpub.net/7728585/viewspace-2133188/ 解析MYSQL BINLOG 二進位制格式(1)--準備工作
http://blog.itpub.net/7728585/viewspace-2133189/ 解析MYSQL BINLOG 二進位制格式(2)--FORMAT_DESCRIPTION_EVENT
http://blog.itpub.net/7728585/viewspace-2133321/ 解析MYSQL BINLOG 二進位制格式(3)--QUERY_EVENT
http://blog.itpub.net/7728585/viewspace-2133429/ 解析MYSQL BINLOG 二進位制格式(4)--TABLE_MAP_EVENT
http://blog.itpub.net/7728585/viewspace-2133463/ 解析MYSQL BINLOG 二進位制格式(5)--WRITE_ROW_EVENT
http://blog.itpub.net/7728585/viewspace-2133469/ 解析MYSQL BINLOG 二進位制格式(6)--UPDATE_ROW_EVENT/DELETE_ROW_EVENT
http://blog.itpub.net/7728585/viewspace-2133502/ 解析MYSQL BINLOG 二進位制格式(7)--Xid_log_event/XID_EVENT
這部分在文件interal中並沒有找到解析,但是透過翻閱原始碼class定義找到一些定義
部分可知,部分未知,如果以後找到會補上,如果有誤請指出
class:Gtid_log_event
event:GTID_LOG_EVENT
event_code:33
class:Gtid_log_event
event:ANONYMOUS_GTID_LOG_EVENT
event_code:34
class:Previous_gtids_log_event
event:PREVIOUS_GTIDS_LOG_EVENT
event_code:35
首先是GTID_LOG_EVENT和ANONYMOUS_GTID_LOG_EVENT
他們源於一個class
(
ANONYMOUS: gtid_mode [ON ON_PERMISSIVE]
非ANONYMOUS:gtid_mode [OFF OFF_PERMISSIVE]
)
只是ANONYMOUS基本沒有填充值,我們來看看原始碼中對他們的定義:
位置在:
Control_events.h 中
protected:
static const int ENCODED_FLAG_LENGTH= 1;
static const int ENCODED_SID_LENGTH= 16;// Uuid::BYTE_LENGTH;
static const int ENCODED_GNO_LENGTH= 8;
/// Length of typecode for logical timestamps.
static const int LOGICAL_TIMESTAMP_TYPECODE_LENGTH= 1;
/// Length of two logical timestamps.
static const int LOGICAL_TIMESTAMP_LENGTH= 16;
// Type code used before the logical timestamps.
static const int LOGICAL_TIMESTAMP_TYPECODE= 2;
gtid_info gtid_info_struct;
Uuid Uuid_parent_struct;
public:
/// Total length of post header
static const int POST_HEADER_LENGTH=
ENCODED_FLAG_LENGTH /* flags */ 1
ENCODED_SID_LENGTH /* SID length */ 16
ENCODED_GNO_LENGTH /* GNO length */ 8
LOGICAL_TIMESTAMP_TYPECODE_LENGTH /* length of typecode */ 1
LOGICAL_TIMESTAMP_LENGTH; /* length of two logical timestamps */ 16
我們可以明確看出GITD儲存的地方ENCODED_SID_LENGTH 16,ENCODED_GNO_LENGTH 8
LOGICAL_TIMESTAMP_LENGTH 兩個8位元組分別表示last_committed,sequence_number
,在ANONYMOUS GTID除了last_committed,sequence_number其他字節為0X00
來具體解析一個:
Gtid_log_event/GTID_LOG_EVENT
# Position Timestamp Type Master ID Size Master Pos Flags
# c2 05 01 9d 58 21 e5 6b 01 00 41 00 00 00 03 01 00 00 00 00
# d5 01 4a 6f 2a 67 5d 87 11 e6 a6 bd 00 0c 29 a8 79 |.Jo.g..........y|
# e5 a3 f0 43 0f 00 00 00 00 00 02 00 00 00 00 00 00 |..C.............|
# f5 00 00 01 00 00 00 00 00 00 00 7d 32 90 b4 |...........2..|
# GTID [commit=yes]
SET @@SESSION.GTID_NEXT= '4a6f2a67-5d87-11e6-a6bd-000c29a879a3:1000432'/*!*/;
01:flags未知
4a 6f 2a 67 5d 87 11 e6 a6 bd 00 0c 29 a8 79 a3: 4a6f2a67-5d87-11e6-a6bd-000c29a879a3
f0 43 0f 00 00 00 00 00 : 小端顯示0X0f43f0,1000432
02:length of typecode未知
00 00 00 00 00 00 00 00:last_committed
01 00 00 00 00 00 00 00: sequence_number
7d 32 90 b4 :CRC32校驗
那看一個ANONYMOUS的
# at 194
#170214 4:12:30 server id 93157 end_log_pos 259 CRC32 0x0901e014
# Position Timestamp Type Master ID Size Master Pos Flags
# c2 2e 13 a2 58 22 e5 6b 01 00 41 00 00 00 03 01 00 00 00 00
# d5 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
# e5 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................|
# f5 00 00 01 00 00 00 00 00 00 00 14 e0 01 09 |..............|
# GTID [commit=yes]
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
除了last_committed 和sequence_number作為組提交的標誌,其他位基本都為0及沒有gtid生成
PREVIOUS_GTIDS_LOG_EVENT:用於表示上一個binlog最後一個gitd的位置,每個binlog只有一個
# at 123
#170214 4:46:24 server id 93157 end_log_pos 194 CRC32 0xd10caea6
# Position Timestamp Type Master ID Size Master Pos Flags
# 7b 20 1b a2 58 23 e5 6b 01 00 47 00 00 00 c2 00 00 00 80 00
# 8e 01 00 00 00 00 00 00 00 4a 6f 2a 67 5d 87 11 e6 |........Jo.g....|
# 9e a6 bd 00 0c 29 a8 79 a3 01 00 00 00 00 00 00 00 |......y.........|
# ae 01 00 00 00 00 00 00 00 05 44 0f 00 00 00 00 00 |.........D......|
# be a6 ae 0c d1 |....|
# Previous-GTIDs
# 4a6f2a67-5d87-11e6-a6bd-000c29a879a3:1-1000452
關於這部分解析位置特別是1-1000452的解析。如果以後知道了補上
只是在原始碼註釋中找到:
/**
@class Previous_gtids_event
@section Previous_gtids_event_binary_format Binary Format
The Post-Header for this event type is empty. The Body has two
components:
*/
但是不知道解析方法。
其他EVENT:
這部分列出的event可以直接參考internals 20章 比較簡單就不用再開文章寫了
Stop_log_event/STOP_EVENT(03):資料庫關閉,或者SLAVE執行了reset slave。
Rotate_log_event/ROTATE_EVENT(04):binlog切換事件,比如超過引數設定。如果伺服器CRASH不會記錄
Intvar_log_event/INTVAR_EVENT(05):和自增欄位有關
Rand_log_event/RAND_EVENT(13):和RAND()函式相關
還有很多和load data infile 有關的event這裡就不考慮了。因為平時我們用load data infile 並不多,這裡主要考慮
和事物有關的各種的event
上接
http://blog.itpub.net/7728585/viewspace-2133188/ 解析MYSQL BINLOG 二進位制格式(1)--準備工作
http://blog.itpub.net/7728585/viewspace-2133189/ 解析MYSQL BINLOG 二進位制格式(2)--FORMAT_DESCRIPTION_EVENT
http://blog.itpub.net/7728585/viewspace-2133321/ 解析MYSQL BINLOG 二進位制格式(3)--QUERY_EVENT
http://blog.itpub.net/7728585/viewspace-2133429/ 解析MYSQL BINLOG 二進位制格式(4)--TABLE_MAP_EVENT
http://blog.itpub.net/7728585/viewspace-2133463/ 解析MYSQL BINLOG 二進位制格式(5)--WRITE_ROW_EVENT
http://blog.itpub.net/7728585/viewspace-2133469/ 解析MYSQL BINLOG 二進位制格式(6)--UPDATE_ROW_EVENT/DELETE_ROW_EVENT
http://blog.itpub.net/7728585/viewspace-2133502/ 解析MYSQL BINLOG 二進位制格式(7)--Xid_log_event/XID_EVENT
這部分在文件interal中並沒有找到解析,但是透過翻閱原始碼class定義找到一些定義
部分可知,部分未知,如果以後找到會補上,如果有誤請指出
class:Gtid_log_event
event:GTID_LOG_EVENT
event_code:33
class:Gtid_log_event
event:ANONYMOUS_GTID_LOG_EVENT
event_code:34
class:Previous_gtids_log_event
event:PREVIOUS_GTIDS_LOG_EVENT
event_code:35
首先是GTID_LOG_EVENT和ANONYMOUS_GTID_LOG_EVENT
他們源於一個class
(
ANONYMOUS: gtid_mode [ON ON_PERMISSIVE]
非ANONYMOUS:gtid_mode [OFF OFF_PERMISSIVE]
)
只是ANONYMOUS基本沒有填充值,我們來看看原始碼中對他們的定義:
位置在:
Control_events.h 中
protected:
static const int ENCODED_FLAG_LENGTH= 1;
static const int ENCODED_SID_LENGTH= 16;// Uuid::BYTE_LENGTH;
static const int ENCODED_GNO_LENGTH= 8;
/// Length of typecode for logical timestamps.
static const int LOGICAL_TIMESTAMP_TYPECODE_LENGTH= 1;
/// Length of two logical timestamps.
static const int LOGICAL_TIMESTAMP_LENGTH= 16;
// Type code used before the logical timestamps.
static const int LOGICAL_TIMESTAMP_TYPECODE= 2;
gtid_info gtid_info_struct;
Uuid Uuid_parent_struct;
public:
/// Total length of post header
static const int POST_HEADER_LENGTH=
ENCODED_FLAG_LENGTH /* flags */ 1
ENCODED_SID_LENGTH /* SID length */ 16
ENCODED_GNO_LENGTH /* GNO length */ 8
LOGICAL_TIMESTAMP_TYPECODE_LENGTH /* length of typecode */ 1
LOGICAL_TIMESTAMP_LENGTH; /* length of two logical timestamps */ 16
我們可以明確看出GITD儲存的地方ENCODED_SID_LENGTH 16,ENCODED_GNO_LENGTH 8
LOGICAL_TIMESTAMP_LENGTH 兩個8位元組分別表示last_committed,sequence_number
,在ANONYMOUS GTID除了last_committed,sequence_number其他字節為0X00
/* Binlog-specific logical timestamps. */
/*
Store for the transaction's commit parent sequence_number.
The value specifies this transaction dependency with a "parent"
transaction.
The member is assigned, when the transaction is about to commit
in binlog to a value of the last committed transaction's sequence_number.
This and last_committed as numbers are kept ever incremented
regardless of binary logs being rotated or when transaction
is logged in multiple pieces.
However the logger to the binary log may convert them
according to its specification.
*/
int64 last_committed;
/*
The transaction's private logical timestamp assigned at the
transaction prepare phase. The timestamp enumerates transactions
in the binary log. The value is gained through incrementing (stepping) a
global clock.
Eventually the value is considered to increase max_committed_transaction
system clock when the transaction has committed.
*/
int64 sequence_number;
/*
Store for the transaction's commit parent sequence_number.
The value specifies this transaction dependency with a "parent"
transaction.
The member is assigned, when the transaction is about to commit
in binlog to a value of the last committed transaction's sequence_number.
This and last_committed as numbers are kept ever incremented
regardless of binary logs being rotated or when transaction
is logged in multiple pieces.
However the logger to the binary log may convert them
according to its specification.
*/
int64 last_committed;
/*
The transaction's private logical timestamp assigned at the
transaction prepare phase. The timestamp enumerates transactions
in the binary log. The value is gained through incrementing (stepping) a
global clock.
Eventually the value is considered to increase max_committed_transaction
system clock when the transaction has committed.
*/
int64 sequence_number;
來具體解析一個:
Gtid_log_event/GTID_LOG_EVENT
# Position Timestamp Type Master ID Size Master Pos Flags
# c2 05 01 9d 58 21 e5 6b 01 00 41 00 00 00 03 01 00 00 00 00
# d5 01 4a 6f 2a 67 5d 87 11 e6 a6 bd 00 0c 29 a8 79 |.Jo.g..........y|
# e5 a3 f0 43 0f 00 00 00 00 00 02 00 00 00 00 00 00 |..C.............|
# f5 00 00 01 00 00 00 00 00 00 00 7d 32 90 b4 |...........2..|
# GTID [commit=yes]
SET @@SESSION.GTID_NEXT= '4a6f2a67-5d87-11e6-a6bd-000c29a879a3:1000432'/*!*/;
01:flags未知
4a 6f 2a 67 5d 87 11 e6 a6 bd 00 0c 29 a8 79 a3: 4a6f2a67-5d87-11e6-a6bd-000c29a879a3
f0 43 0f 00 00 00 00 00 : 小端顯示0X0f43f0,1000432
02:length of typecode未知
00 00 00 00 00 00 00 00:last_committed
01 00 00 00 00 00 00 00: sequence_number
7d 32 90 b4 :CRC32校驗
那看一個ANONYMOUS的
# at 194
#170214 4:12:30 server id 93157 end_log_pos 259 CRC32 0x0901e014
# Position Timestamp Type Master ID Size Master Pos Flags
# c2 2e 13 a2 58 22 e5 6b 01 00 41 00 00 00 03 01 00 00 00 00
# d5 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
# e5 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................|
# f5 00 00 01 00 00 00 00 00 00 00 14 e0 01 09 |..............|
# GTID [commit=yes]
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
除了last_committed 和sequence_number作為組提交的標誌,其他位基本都為0及沒有gtid生成
PREVIOUS_GTIDS_LOG_EVENT:用於表示上一個binlog最後一個gitd的位置,每個binlog只有一個
# at 123
#170214 4:46:24 server id 93157 end_log_pos 194 CRC32 0xd10caea6
# Position Timestamp Type Master ID Size Master Pos Flags
# 7b 20 1b a2 58 23 e5 6b 01 00 47 00 00 00 c2 00 00 00 80 00
# 8e 01 00 00 00 00 00 00 00 4a 6f 2a 67 5d 87 11 e6 |........Jo.g....|
# 9e a6 bd 00 0c 29 a8 79 a3 01 00 00 00 00 00 00 00 |......y.........|
# ae 01 00 00 00 00 00 00 00 05 44 0f 00 00 00 00 00 |.........D......|
# be a6 ae 0c d1 |....|
# Previous-GTIDs
# 4a6f2a67-5d87-11e6-a6bd-000c29a879a3:1-1000452
關於這部分解析位置特別是1-1000452的解析。如果以後知道了補上
只是在原始碼註釋中找到:
/**
@class Previous_gtids_event
@section Previous_gtids_event_binary_format Binary Format
The Post-Header for this event type is empty. The Body has two
components:
Name | Format | Description |
---|---|---|
buf | unsigned char array |
It contains the Gtids executed in the last binary log file. |
buf_size | 4 byte integer | Size of the above buffer |
*/
但是不知道解析方法。
其他EVENT:
這部分列出的event可以直接參考internals 20章 比較簡單就不用再開文章寫了
Stop_log_event/STOP_EVENT(03):資料庫關閉,或者SLAVE執行了reset slave。
Rotate_log_event/ROTATE_EVENT(04):binlog切換事件,比如超過引數設定。如果伺服器CRASH不會記錄
Intvar_log_event/INTVAR_EVENT(05):和自增欄位有關
Rand_log_event/RAND_EVENT(13):和RAND()函式相關
還有很多和load data infile 有關的event這裡就不考慮了。因為平時我們用load data infile 並不多,這裡主要考慮
和事物有關的各種的event
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7728585/viewspace-2133506/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 解析MYSQL BINLOG二進位制格式(9)--infobin解析binlog幫助文件MySql
- 解析MYSQL BINLOG二進位制格式(10)--問題解答MySql
- 解析MYSQL BINLOG 二進位制格式(1)--準備工作MySql
- 解析MYSQL BINLOG 二進位制格式(3)--QUERY_EVENTMySql
- 解析MYSQL BINLOG 二進位制格式(4)--TABLE_MAP_EVENTMySql
- 解析MYSQL BINLOG 二進位制格式(5)--WRITE_ROW_EVENTMySql
- 解析MYSQL BINLOG 二進位制格式(2)--FORMAT_DESCRIPTION_EVENTMySqlORM
- 解析MYSQL BINLOG 二進位制格式(6)--UPDATE_ROW_EVENT/DELETE_ROW_EVENTMySqldelete
- MySQL二進位制檔案(binlog)MySql
- 解析MYSQL BINLOG 二進位制格式(7)--Xid_log_event/XID_EVENTMySql
- Java二進位制Class檔案格式解析Java
- mysql二進位制日誌格式介紹MySql
- 如何在MySQL中檢視binlog二進位制日誌?MySql
- office檔案格式複合文件二進位制結構解析
- 進位制與二進位制及相關轉換
- MySQL二進位制日誌MySql
- mysql 二進位制日誌MySql
- mysql5.7 for windows二進位制安裝及配置MySqlWindows
- mixed模式下的binlog二進位制日誌解析,需要加-v引數模式
- python進位制轉換(二進位制、十進位制和十六進位制)及注意事項Python
- 二進位制求5個1的格式。。。。
- Mysql二進位制包安裝MySql
- 管理mysql二進位制日誌MySql
- mysql的二進位制日誌MySql
- 二進位制與二進位制運算
- k8s二進位制部署K8S
- 進位制詳解:二進位制、八進位制和十六進位制
- [MySQL binlog]徹底解析Mixed日誌格式的binlogMySql
- JavaScript 二進位制、八進位制與十六進位制JavaScript
- MySQL二進位制日誌的三種格式優缺點比較MySql
- mysql安裝-----二進位制包安裝及解除安裝MySql
- MySQL 壓縮二進位制日誌MySql
- mysql二進位制日誌詳解MySql
- MySQL linux二進位制安裝MySqlLinux
- mysql 二進位制日誌總結MySql
- 利用vstruct解析二進位制資料Struct
- (二進位制)
- 二進位制