innodb_flush_method 用来控制innodb的redo日志文件和data数据文件采用何种flush方法。类unix/linux操作系统的取值为:fsync/0 ,O_DSYNC/1, littlesync/2 ,nosync/3 ,O_DIRECT/4 ,O_DIRECT_NO_FSYNC/5。默认取值
fsync ;windows操作系统下的取值为: unbuffered/0 , normal/1 。默认值
unbuffered。
先看看官方文档的说明:
or
fsync0
: InnoDB
uses the fsync()
system call to flush both the data and log files. fsync
is the default setting. innodb使用fsync()系统调用刷新数据和日志文件;
or
O_DSYNC1
: InnoDB
uses O_SYNC
to open and flush the log files, and fsync()
to flush the data files. InnoDB
does not use O_DSYNC
directly because there have been problems with it on many varieties of Unix. innodb使用O_SYNC flag打开并刷新日志文件,并且使用fsync()系统调用刷新数据文件。innodb没有将O_DSYNC作为默认值使用,因为在有一些变种unix系统上,O_DSYNC实现的有问题;
or
littlesync2
: This option is used for internal performance testing and is currently unsupported. Use at your own risk.截至目前8.0.22版本,仅作内部测试用;
or
nosync3
: This option is used for internal performance testing and is currently unsupported. Use at your own risk.截至目前8.0.22版本,仅作内部测试用;
or
O_DIRECT4
: InnoDB
uses O_DIRECT
(or directio()
on Solaris) to open the data files, and uses fsync()
to flush both the data and log files. This option is available on some GNU/Linux versions, FreeBSD, and Solaris. innodb使用O_DIRECT flag(或者在Solaris系统上使用directio()系统调用)打开数据文件,并且使用fsync()系统调用刷新数据和日志文件。
:
O_DIRECT_NO_FSYNCInnoDB
uses O_DIRECT
during flushing I/O, but skips the fsync()
system call after each write operation.innodb使用O_DIRECT打开文件,但是在写操作之后跳过使用fsync()系统调用刷新。
:
unbufferedInnoDB
uses simulated asynchronous I/O and non-buffered I/O.innodb使用仿真的异步和非缓存io;
or
normal1
: InnoDB
uses simulated asynchronous I/O and buffered I/O.innodb使用仿真的异步和缓存io;
这里主要说unix/linux操作系统。
上面列出的所有的刷新参数,涉及到4个系统调用open(),write(