溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

sync_binlog

發(fā)布時(shí)間:2020-08-17 00:30:17 來源:ITPUB博客 閱讀:177 作者:哎呀我的天吶 欄目:MySQL數(shù)據(jù)庫
5.6默認(rèn)值0,到了5.7默認(rèn)是1

sync_binlog

Command-Line Format --sync-binlog=#
System Variable Name sync_binlog
Variable Scope Global
Dynamic Variable Yes
Permitted Values (32-bit platforms) Type integer
Default 0
Min Value 0
Max Value 4294967295
Permitted Values (64-bit platforms) Type integer
Default 0
Min Value 0
Max Value 4294967295

If the value of this variable is greater than 0, the MySQL server synchronizes its binary log to disk (using fdatasync()) after sync_binlog commit groups are written to the binary log. The default value of sync_binlog is 0, which does no synchronizing to disk—in this case, the server relies on the operating system to flush the binary log's contents from time to time as for any other file. A value of 1 is the safest choice because in the event of a crash you lose at most one commit group from the binary log. However, it is also the slowest choice (unless the disk has a battery-backed cache, which makes synchronization very fast).

百度翻譯:如果這個(gè)變量的值大于0,MySQL服務(wù)器同步二進(jìn)制日志到磁盤(使用fdatasync())后sync_binlog犯組寫入二進(jìn)制日志。sync_binlog的默認(rèn)值是0,并沒有同步在這種情況下,磁盤,服務(wù)器依賴于操作系統(tǒng)的二進(jìn)制日志的內(nèi)容刷新時(shí)間為任何其他文件。一個(gè)1的值是最安全的選擇,因?yàn)樵谝粋€(gè)崩潰的事件,你失去了最一個(gè)提交組從二進(jìn)制日志。然而,它也是最慢的選擇(除非磁盤具有電池備份的高速緩存,這使得同步非??欤?。



sync_binlog=1 or N
     This makes MySQL synchronize the binary log’s contents to disk each time it commits a transaction 
     默認(rèn)情況下,并不是每次寫入時(shí)都將binlog與硬盤同步。因此如果操作系統(tǒng)或機(jī)器(不僅僅是MySQL服務(wù)器)崩潰,有可能binlog中最后的語句丟 失了。要想防止這種情況,你可以使用sync_binlog全局變量(1是最安全的值,但也是最慢的),使binlog在每N次binlog寫入后與硬盤 同步。即使sync_binlog設(shè)置為1,出現(xiàn)崩潰時(shí),也有可能表內(nèi)容和binlog內(nèi)容之間存在不一致性。如果使用InnoDB表,MySQL服務(wù)器 處理COMMIT語句,它將整個(gè)事務(wù)寫入binlog并將事務(wù)提交到InnoDB中。如果在兩次操作之間出現(xiàn)崩潰,重啟時(shí),事務(wù)被InnoDB回滾,但仍 然存在binlog中??梢杂?-innodb-safe-binlog選項(xiàng)來增加InnoDB表內(nèi)容和binlog之間的一致性。(注釋:在MySQL 5.1中不需要--innodb-safe-binlog;由于引入了XA事務(wù)支持,該選項(xiàng)作廢了),該選項(xiàng)可以提供更大程度的安全,使每個(gè)事務(wù)的 binlog(sync_binlog =1)和(默認(rèn)情況為真)InnoDB日志與硬盤同步,該選項(xiàng)的效果是崩潰后重啟時(shí),在滾回事務(wù)后,MySQL服務(wù)器從binlog剪切回滾的 InnoDB事務(wù)。這樣可以確保binlog反饋InnoDB表的確切數(shù)據(jù)等,并使從服務(wù)器保持與主服務(wù)器保持同步(不接收 回滾的語句)。
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI