innodb_flush_log_at_trx_commit

  • Post author:
  • Post category:其他


Controls the balance between strict ACID compliance for commit operations and higher performance that is possible when commit-related I/O operations are rearranged and done in batches. You can achieve better performance by changing the default value but then you can lose transactions in a crash.

控制二者的平衡–提交操作遵守严格ACID特性和相关提交操作被重新排列并分批完成的高性能的可能性。您可以通过更改默认值来获得更好的性能,但是在崩溃时可能会丢失事务。

• The default setting of 1 is required for full ACID compliance. Logs are written and flushed to disk at each transaction commit.

默认值是1,完成遵守ACID特性。每次事务提交时,日志都会写入并刷新到磁盘。

• With a setting of 0, logs are written and flushed to disk once per second. Transactions for which

logs have not been flushed can be lost in a crash.

设置为0时,日志每秒写入并刷新到磁盘一次。未刷新日志的事务可能会在崩溃中丢失。

• With a setting of 2, logs are written after each transaction commit and flushed to disk once per

second. Transactions for which logs have not been flushed can be lost in a crash.

设置为2时,日志在每次事务提交后写入,并每秒刷新一次到磁盘。未刷新日志的事务可能会在崩溃中丢失。

• For settings 0 and 2, once-per-second flushing is not 100% guaranteed. Flushing may occur

more frequently due to DDL changes and other internal InnoDB activities that cause logs to be

flushed independently of the innodb_flush_log_at_trx_commit setting, and sometimes

less frequently due to scheduling issues. If logs are flushed once per second, up to one second

of transactions can be lost in a crash. If logs are flushed more or less frequently than once per

second, the amount of transactions that can be lost varies accordingly

对于设置0和2,不能100%保证每秒flush一次。刷新可能会更频繁地发生,因为DDL更改和其他内部InnoDB活动会导致日志的刷新独立于 innodb_flush_log_at_trx_commit设置,有时由于调度问题而不太频繁。如果日志每秒刷新一次,则在崩溃中最多会丢失一秒钟的事务。如果日志刷新频率大于或小于每秒一次,则可能丢失的事务量也会相应变化。

• Log flushing frequency is controlled by innodb_flush_log_at_timeout, which allows you

to set log flushing frequency to N seconds (where N is 1 … 2700, with a default value of 1).

However, any mysqld process crash can erase up to N seconds of transactions.

日志刷新频率由innodb_flush_log_at_timeout超时控制,允许将日志刷新频率设置为N秒(其中N是1。。。2700,默认值为1)。但是,任何mysqld进程崩溃都可以擦除多达N秒的事务。

• DDL changes and other internal InnoDB activities flush the log independently of the

innodb_flush_log_at_trx_commit setting.

DDL更改和其他InnoDB内部活动独立于innodb_flush_log_at_trx_commit设置。

• InnoDB crash recovery works regardless of the innodb_flush_log_at_trx_commit setting.

Transactions are either applied entirely or erased entirely.

无论innodb_flush_log_at_trx_commit设置如何,InnoDB崩溃恢复都可以工作。

事务要么被完全应用,要么被完全删除。


For durability and consistency in a replication setup that uses InnoDB with transactions:

• If binary logging is enabled, set sync_binlog=1.

• Always set innodb_flush_log_at_trx_commit=1.

对于使用InnoDB处理事务的复制设置的持久性和一致性:

如果启用了二进制日志记录,请将sync_binlog设置为1。

总是将innodb_flush_log_at_trx_commit=1。

许多操作系统和一些磁盘硬件愚弄了磁盘刷新操作。

他们可能会告诉mysqld,冲水已经发生了,尽管还没有发生。在这种情况下,即使使用推荐的设置也不能保证事务的持久性,在最坏的情况下,断电会损坏InnoDB数据。

在SCSI磁盘控制器或磁盘本身中使用电池备份的磁盘缓存可以加快文件刷新速度,并使操作更安全。

您还可以尝试禁用硬件缓存中磁盘写入的缓存。



版权声明:本文为u013469501原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。