Geek time – Lin Xiaobin -MySQL combat 45 talk collated from

We know that the MySQL database can restore data to a point in time in history in the event of an unexpected outage. This function relies on logs. MySQL provides two types of logs, and logs in both modules. Redo logs in the storage engine and binlogs in the Server layer

redo log

WAL Logging (write-Ahead Logging) is used in MySQL to update data in memory, and then update data in disk. The key point is to Write the update log first, and then update data in memory. Then update the data on the disk

InnoDB’s redo log is a physical log that records changes made to a particular data page. The files are fixed size. You can configure a group of 4 log files, each 1 gb size, so a total of 4 GB log stores. Because the log size is fixed, the cycle continues from the first log file when full. With redo log InnoDB guarantees that all previously committed data will not be lost after a database restarts. This capability is called crash-safe

binlog

A binlog is a Server log. It is a logical log, such as “update the C field of a row with ID=2 to 1”. The log is appended.

Used to adjust log parameters

Innodb_flush_log_at_trx_commit if set to 1, the redo log of each transaction is persisted directly to disk

The sync_binlog parameter is set to 1, indicating that each transaction binlog is persisted to disk