[英]MySQL Cluster: How to decode/interpret binary logs?
我試圖從我的4節點MySQL集群的二進制日志中獲取一些有用的信息是徒勞的。 作為測試,我於上午11:01在主服務器上手動執行了UPDATE語句(它確實成功更改了表中的某些數據)。 不幸的是,我無法讓mysqlbinlog向我展示執行的語句。
我試過了--verbose選項,-hexdump選項和--base64-output = DECODE-ROWS --verbose。 不管我做什么,實際的語句似乎仍然被編碼(或者應該有一個UPDATE時有一個INSERT INTO)。
以下是我上午11:01測試的相關輸出,並指定了--base64-output = DECODE-ROWS --verbose選項。 為什么找不到我的UPDATE語句? 而且,如果數據庫將其優化為“插入到”,為什么我至少看不到表名和原始語句的其他部分?
# at 1744
#121213 11:01:56 server id 1 end_log_pos 1808 Query thread_id=0 exec_time=0 error_code=0
SET TIMESTAMP=1355425316/*!*/;
BEGIN
/*!*/;
# at 1808
# at 1899
# at 1961
# at 2022
#121213 11:01:56 server id 1 end_log_pos 1899 Table_map: `source_words`.`players` mapped to number 1826
#121213 11:01:56 server id 1 end_log_pos 1961 Table_map: `mysql`.`ndb_apply_status` mapped to number 1817
#121213 11:01:56 server id 1 end_log_pos 2022 Write_rows: table id 1817
#121213 11:01:56 server id 1 end_log_pos 2071 Write_rows: table id 1826 flags: STMT_END_F
### INSERT INTO mysql.ndb_apply_status
### SET
### @1=1
### @2=14197993649471490
### @3=''
### @4=0
### @5=0
### INSERT INTO source_words.players
### SET
### @1='834770J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00!\x00\x00\x00\x00\x00\x00\x00\x17yê\x00\x00\x17yê\x00\x00 \x00\x00\x00\x00\x00\x00\x00À'
### @6=0
# at 2071
#121213 11:01:56 server id 1 end_log_pos 2136 Query thread_id=0 exec_time=0 error_code=0
SET TIMESTAMP=1355425316/*!*/;
COMMIT
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
謝謝,羅伯
binlog記錄了更改的內容,不一定記錄了引起更改的語句(或者,如果更新不更新任何內容,則也不顯示任何內容)。 如果您的BINLOG_FORMAT
是STATEMENT
,那么對於ROW
& MIXED
,將是語句,您將在MySQL認為合適的位置和時間獲得這些條目。 二進制日志不監視/檢查數據庫查詢(為此使用常規查詢日志),二進制日志僅用於記錄數據更改,因此您可以可靠地恢復備份或采用復制。 從來沒有打算讓它可讀。
還要注意,存在可以和不會被二進制記錄的設置,並且您的“默認模式”對連接有很大影響。 如果您確實缺少聲明(請注意舊日志會輪換使用),建議您使用SHOW VARIABLES LIKE '%binlog%';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.