您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“mysql的二進(jìn)制日志是怎樣保存的”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
說明
1、statement基于SQL語句,每個(gè)涉及修改的sql都會(huì)記錄在binlog中。
缺點(diǎn):日志量過大,如sleep()函數(shù)、last_insert_id()>、user-definedfuctions(udf)、主從復(fù)制等。
2、ROW基于行,只記錄變化的記錄,不記錄sql的上下文環(huán)境。
缺點(diǎn):如果遇到update..set..wheretrue,binlog的數(shù)據(jù)量會(huì)增加。
3、建議使用MIXED,語句采用statement。
函數(shù)采用ROW存儲(chǔ)。
實(shí)例
# 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的二進(jìn)制日志是怎樣保存的”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。