您好,登錄后才能下訂單哦!
本篇內容介紹了“mysql的二進制日志是怎樣保存的”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
說明
1、statement基于SQL語句,每個涉及修改的sql都會記錄在binlog中。
缺點:日志量過大,如sleep()函數、last_insert_id()>、user-definedfuctions(udf)、主從復制等。
2、ROW基于行,只記錄變化的記錄,不記錄sql的上下文環境。
缺點:如果遇到update..set..wheretrue,binlog的數據量會增加。
3、建議使用MIXED,語句采用statement。
函數采用ROW存儲。
實例
# lee @ acer in /var/log/mysql [14:45:44] $ mysqlbinlog -vv mysql-bin.000076 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #170713 14:35:53 server id 1 end_log_pos 123 CRC32 0xbf52e415 Start: binlog v 4, server v 5.7.18-0ubuntu0.16.04.1-log created 170713 14:35:53 # Warning: this binlog is either in use or was not closed properly. BINLOG ' yRRnWQ8BAAAAdwAAAHsAAAABAAQANS43LjE4LTB1YnVudHUwLjE2LjA0LjEtbG9nAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA ARXkUr8= '/*!*/; # at 123 #170713 14:35:53 server id 1 end_log_pos 154 CRC32 0xafecf53d Previous-GTIDs # [empty] # at 154 #170713 14:43:03 server id 1 end_log_pos 219 CRC32 0x491b5a7e Anonymous_GTID last_committed=0 sequence_number=1 SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; # at 219 #170713 14:43:03 server id 1 end_log_pos 318 CRC32 0x4acf1cd1 Query thread_id=8 exec_time=0 error_code=0 use `test`/*!*/; SET TIMESTAMP=1499928183/*!*/; SET @@session.pseudo_thread_id=8/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=1436549152/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; alter table t add c2 text /*!*/; # at 318 #170713 14:44:02 server id 1 end_log_pos 383 CRC32 0x8437eaf9 Anonymous_GTID last_committed=1 sequence_number=2 SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; # at 383 #170713 14:44:02 server id 1 end_log_pos 455 CRC32 0x57adaf15 Query thread_id=8 exec_time=0 error_code=0 SET TIMESTAMP=1499928242/*!*/; BEGIN /*!*/; # at 455 #170713 14:44:02 server id 1 end_log_pos 504 CRC32 0xdba65133 Table_map: `test`.`t` mapped to number 498 # at 504 #170713 14:44:02 server id 1 end_log_pos 556 CRC32 0x19769a28 Write_rows: table id 498 flags: STMT_END_F BINLOG ' shZnWRMBAAAAMQAAAPgBAAAAAPIBAAAAAAEABHRlc3QAAXQAAwMP/AMeAAIHM1Gm2w== shZnWR4BAAAANAAAACwCAAAAAPIBAAAAAAEAAgAD//gDAAAABGhhaGEFAGxsYWxhKJp2GQ== '/*!*/; ### INSERT INTO `test`.`t` ### SET ### @1=3 /* INT meta=0 nullable=1 is_null=0 */ ### @2='haha' /* VARSTRING(30) meta=30 nullable=1 is_null=0 */ ### @3='llala' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */ # at 556 #170713 14:44:02 server id 1 end_log_pos 587 CRC32 0x6184a9a1 Xid = 47 COMMIT/*!*/; # at 587 #170713 14:44:16 server id 1 end_log_pos 652 CRC32 0xc585d273 Anonymous_GTID last_committed=2 sequence_number=3 SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; # at 652 #170713 14:44:16 server id 1 end_log_pos 724 CRC32 0x63005380 Query thread_id=8 exec_time=0 error_code=0 SET TIMESTAMP=1499928256/*!*/; BEGIN /*!*/; # at 724 #170713 14:44:16 server id 1 end_log_pos 773 CRC32 0x2c52eaa1 Table_map: `test`.`t` mapped to number 498 # at 773 #170713 14:44:16 server id 1 end_log_pos 816 CRC32 0xa80bd454 Delete_rows: table id 498 flags: STMT_END_F BINLOG ' wBZnWRMBAAAAMQAAAAUDAAAAAPIBAAAAAAEABHRlc3QAAXQAAwMP/AMeAAIHoepSLA== wBZnWSABAAAAKwAAADADAAAAAPIBAAAAAAEAAgAD//wBAAAAAmRkVNQLqA== '/*!*/; ### DELETE FROM `test`.`t` ### WHERE ### @1=1 /* INT meta=0 nullable=1 is_null=0 */ ### @2='dd' /* VARSTRING(30) meta=30 nullable=1 is_null=0 */ ### @3=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */ # at 816 #170713 14:44:16 server id 1 end_log_pos 847 CRC32 0x9d03bcd0 Xid = 48 COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; DELIMITER ; # End of log file /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
“mysql的二進制日志是怎樣保存的”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。