mysql innodb_flush_method_innodb_flush_method

1)打开一个文件时如果加入了O_DIRECT标志位,意味着对该文件的读写操作将会绕过page cache,直接与存储设备打交道,但是这里不保证每次write返回后,该write要写入的数据已经写完。

2)如果是带O_SYNC标志位,则不绕过pape cache, 每次write的数据不仅会在page cache里写入,还会写入存储设备,并且,O_SYNC保证每次write返回后,数据都已经写入page cache和存储设备。

Direct I/O and Data I/O Integrity Completion

Although direct I/O writes are done synchronously, they do not provide synchronized I/O data integrity completion, as defined by POSIX. Applications that need this feature should use O_DSYNC in addition to O_DIRECT. O_DSYNC guarantees that all of the data and enough of the metadata (for example, indirect blocks) have written to the stable store to be able to retrieve the data after a system crash. O_DIRECT only writes the data; it does not write the metadata.

在通常的write中,实际是写的页缓存,页缓存通过周期性的flush(pdflush)或强制回写到磁盘,页缓存回写时,是通过sync_single_inode按inode来回写的,回写过程中会先调用do_writepages回写数据,然后再调用write_inode回写元数据,所以是有先后顺序的,通常也能保证一致性。

innodb_flush_method这个参数控制着innodb数据文件及redo log的打开、刷写模式,对于这个参数,文档上是这样描述的:

有三个值:fdatasync(默认),O_DSYNC,O_DIRECT

默认是fdatasync,调用fsync()去刷数据文件与redo log的buffer

为O_DSYNC时,innodb会使用O_SYNC方式打开和刷写redo log,使用fsync()刷写数据文件

为O_DIRECT时,innodb使用O_DIRECT打开数据文件,使用fsync()刷写数据文件跟redo log

Command-Line Format

--innodb_flush_method=name

System Variable Name

innodb_flush_method

Variable Scope

Global

Dynamic Variable

No

Permitted Values

Type (Windows)

string

Default

async_unbuffered

Permitted Values (<= 5.1.23)

Type (Unix)

string

Default

fdatasync

Valid Values

fdatasync

O_DSYNC

O_DIRECT

Permitted Values (>= 5.1.24)

Type (Unix)

string

Default

fsync

Valid Values

fsync

O_DSYNC

O_DIRECT

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值