【MySQL 5.7 Reference Manual】15.4.7 Doublewrite Buffer(双写缓冲)

来源:互联网 发布:浴霸哪个牌子好 知乎 编辑:程序博客网 时间:2024/06/08 19:46
15.4.7 Doublewrite Buffer(双写缓冲)

The doublewrite buffer is a storage area located in the system tablespace where InnoDB writes pages that are flushed from the InnoDB buffer pool, before the pages are written to their proper positions in the data file. Only after flushing and writing pages to the doublewrite buffer, does InnoDB write pages to their proper positions. If there is an operating system, storage subsystem, or mysqld process crash in the middle of a page write, InnoDB can later find a good copy of the page from the doublewrite buffer during crash recovery.

双写缓冲是一个位于系统表空间中的存储区域,InnoDB缓冲池中刷出的页在被写入数据文件的适当位置之前会先写入这里。只有把页刷出并写入到双写缓冲之后,InnoDB才会把页写入到适当位置。假如此时操作系统、存储子系统或mysqld进程在页写到一半时崩溃,InnoDB在之后溃恢复期间可以从双写缓冲中找到一个完好的页拷贝。

Although data is always written twice, the doublewrite buffer does not require twice as much I/O overhead or twice as many I/O operations. Data is written to the doublewrite buffer,itself as a large sequential chunk, with a single fsync() call to the operating system.

虽然数据总是写两次,但双写缓冲并不需要两倍的I/O开销或者两倍的其他I/O操作。数据写入双写缓冲后,其本身是一个大型的连续块,会通过一次fsync()通知操作系统。

The doublewrite buffer is enabled by default in most cases. To disable the doublewrite buffer, set innodb_doublewrite to 0.

双写缓冲在大多数场景下都是默认有效的。可以通过设置innodb_doublewrite为0来关闭双写缓冲。

As of MySQL 5.7.4, if system tablespace files (“ibdata files”) are located on Fusion-io devices that support atomic writes, doublewrite buffering is automatically disabled and Fusion-io atomic writes are used for all data files. Because the doublewrite buffer setting is global, doublewrite buffering is also disabled for data files residing on non-Fusion-io hardware. This feature is only supported on Fusion-io hardware and is only enabled for Fusion-io NVMFS on Linux. To take full advantage of this feature, an innodb_flush_method setting of O_DIRECT is recommended.

自MySQL 5.7.4开始,如果系统表空间文件(“ibdata文件”)位于Fusion-io设备(支持原子写),双写缓冲自动失效并且Fusion-io原子写会被用于所有数据文件。由于双写缓冲设置是全局的,双写缓冲也会在位于非Fusion-io硬件的数据文件上失效。该特性仅支持Fusion-io硬件并且只能通过Linux系统上的Fusion-io NVMFS启用。为了充分利用该特性,O_DIRECT推荐使用innodb_flush_method设置。
0 0
原创粉丝点击