2012-12-13 193 views
0

我試圖徒勞地從我的4節點MySQL集羣的二進制日誌中獲取一些有用的信息。作爲一個測試,我在主機上的11:01手動執行了UPDATE語句(並且它成功地更改了表中的一些數據)。不幸的是,我不能讓mysqlbinlog向我展示執行的語句。MySQL集羣:如何解碼/解釋二進制日誌?

我試過--verbose選項,--hexdump選項和--base64-output = DECODE-ROWS --verbose。不管我做什麼,實際的語句似乎仍然是編碼的(或者當應該有UPDATE時有INSERT INTO)。

下面是我的11:01 am測試的相關輸出,其中指定了--base64-output = DECODE-ROWS --verbose選項。爲什麼我的UPDATE語句無處可查?而且,如果數據庫將其優化爲INSERT INTO,爲什麼我至少不能看到我原來的語句的表名和其他部分?

# 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 [email protected]_COMPLETION_TYPE*/; 

感謝, 羅布

回答

1

的二進制日誌記錄什麼塗改,不一定什麼說法引起了它(或者,如果更新不更新什麼,什麼都不會被任何顯示)。如果你的BINLOG_FORMATSTATEMENT,那麼al會是語句,對於ROW & MIXED,你會在MySQL認爲它適合的地方和時間獲得這些條目。 binlog不會監視/檢查數據庫上的查詢(使用通用查詢日誌),binlog僅用於記錄數據更改,因此您可以可靠地恢復備份或採用複製。它從來沒有打算成爲人類可讀的。

另請注意,有可能的設置將會和不會被綁定,並且您的「默認模式」對連接有相當大的影響。如果你真的錯過了一個聲明(注意舊日誌得到旋轉),我建議SHOW VARIABLES LIKE '%binlog%';