Innodb_flush_log_at_trx_commit and Sync_binlog two parameters are key parameters for controlling MySQL disk write policy and data security.
If Innodb_flush_log_at_trx_commit is set to 0,log buffer, it is written to log file once per second, and the flush (swipe to disk) operation of log file is performed concurrently.
In this mode, the operation to write to the disk is not actively triggered when the transaction commits.
If Innodb_flush_log_at_trx_commit is set to 1, MySQL writes log buffer data to log file each time the transaction commits, and flush (swipe to disk).
If Innodb_flush_log_at_trx_commit is set to 2, MySQL writes log buffer data to log file each time the transaction commits. But the flush (brushed to disk) operation does not work at the same time.
In this mode, MySQL executes the flush (swipe to disk) operation once per second.
Sync_binlog
The default value of Sync_binlog is 0, like the mechanism of the operating system brushing other files, MySQL does not sync to disk but relies on the operating system to flush binary logs.
When Sync_binlog =n (n>0), MySQL synchronizes its binary log binary logs to disk using the Fdatasync () function when it writes N binary log binary logs every nth time.
MySQL Dual 1 Setup