[MySQL] 参数: innodb_flush_log_at_trx_commit和sync_binlog
MySQL参数: innodb_flush_log_at_trx_commit和sync_binlog
innodb_flush_log_at_trx_commit和sync_binlog是MySQL控制磁盘写入策略的重要参数.
innodb_flush_log_at_trx_commit

当
innodb_flush_log_at_trx_commit=0时, log buffer将每秒一次地写入log file, 并且log file的flush(刷新到disk)操作同时进行. 此时, 事务提交是不会主动触发写入磁盘的操作.当
innodb_flush_log_at_trx_commit=1时(默认), 每次事务提交时, MySQL会把log buffer的数据写入log file, 并且将log file flush(刷新到disk)中去.当
innodb_flush_log_at_trx_commit=2时, 每次事务提交时, MySQL会把log buffer的数据写入log file, 但不会主动触发flush(刷新到disk)操作同时进行. 然而, MySQL会每秒执行一次flush(刷新到disk)操作.然而, 每秒flush并不能确保100%每秒发生, 因为os调度问题.
默认的1可以获得更好地数据安全, 但性能会打折扣. 不过非1时, 在遇到crash可能会丢失1秒的事务; 设置为0时, 任何mysqld进程crash会丢失上1秒的事务; 设置为2时, 任何os crash或者机器掉电会丢失上1秒的事务; InnoDB的crash recovery运行时会忽略这些数据.
sync_binlog

当
sync_binlog=0时(默认), 如os刷新其他文件的机制一样, MySQL不会刷新log buffer到disk中去, 而是依赖os机制刷新log buffer数据到binary log中.当
sync_binlog=1时, MySQL在写1次二进制日志binary log时, 会使用fdatasync()函数将二进制binary log同步到disk中去.(安全性最高的配置)当
sync_binlog=N(N>1)时, MySQL在写N次二进制日志binary log时, 会使用fdatasync()函数将二进制binary log同步到disk中去.
当两个参数设置为双1的时候, 写入性能最差. 当sync_binlog=N(N>1) && innodb_flush_log_at_trx_commit=2, MySQL的写操作才能达到最高性能.

ref:
https://dev.mysql.com/doc/refman/5.5/en/innodb-parameters.html
[MySQL] 参数: innodb_flush_log_at_trx_commit和sync_binlog的更多相关文章
- MySQL参数: innodb_flush_log_at_trx_commit和sync_binlog
innodb_flush_log_at_trx_commit 当innodb_flush_log_at_trx_commit=0时, log buffer将每秒一次地写入log file, 并且log ...
- mysql 开发进阶篇系列 19 MySQL Server(innodb_flush_log_at_trx_commit与sync_binlog)
一. innodb_flush_log_at_trx_commit 这个参数名称有个log,一看就是与日志有关.是指:用来控制缓冲区(log buffer)中的数据写入到日志文件(log file), ...
- mysql参数innodb_flush_log_at_trx_commit
查看mysql数据库innodb_flush_log_at_trx_commit : mysql> SHOW GLOBAL VARIABLES LIKE 'innodb_flush_log%'; ...
- MySQL 重要参数 innodb_flush_log_at_trx_commit 和 sync_binlog
innodb_flush_log_at_trx_commit 主要控制了innodb将log buffer中的数据写入日志文件并flush磁盘的时间点,取值分别为0.1.2三个.该参数控制重做日志写入 ...
- MySQL参数:innodb_flush_log_at_trx_commit 和 sync_binlog
innodb_flush_log_at_trx_commit 和 sync_binlog 是 MySQL 的两个配置参数,前者是 InnoDB 引擎特有的.之所以把这两个参数放在一起讨论,是因为在实际 ...
- 有关mysql的innodb_flush_log_at_trx_commit参数
一.参数解释 0:log buffer将每秒一次地写入log file中,并且log file的flush(刷到磁盘)操作同时进行.该模式下在事务提交的时候,不会主动触发写入磁盘的操作. 1:每次事务 ...
- 有关mysql的innodb_flush_log_at_trx_commit参数【转】
一.参数解释 0:log buffer将每秒一次地写入log file中,并且log file的flush(刷到磁盘)操作同时进行.该模式下在事务提交的时候,不会主动触发写入磁盘的操作. 1:每次事务 ...
- innodb_flush_log_at_trx_commit和sync_binlog参数详解
innodb_flush_log_at_trx_commit和sync_binlog参数详解 标签: innodb_flush_ ...
- innodb_flush_log_at_trx_commit 和 sync_binlog 参数详 解
"innodb_flush_log_at_trx_commit"和"sync_binlog"两个参数是控制 MySQL 磁盘写入策略以及数据安全性的关键参数.当 ...
随机推荐
- [CodeForces - 296D]Greg and Graph(floyd)
Description 题意:给定一个有向图,一共有N个点,给邻接矩阵.依次去掉N个节点,每一次去掉一个节点的同时,将其直接与当前节点相连的边和当前节点连出的边都需要去除,输出N个数,表示去掉当前节点 ...
- 笔记-pytho-语法-yield
笔记-python-语法-yield 1. yield 1.1. yield基本使用 def fab(max): n,a,b = 0, 0, 1 while n < max: y ...
- CSS3 Flexbox(伸缩盒/弹性盒模型)可视化指南
在http://css.doyoe.com/(CSS参考手册)中,本文对应其中的伸缩盒 引入 Flexbox布局官方称为CSS Flexible Box Layout Module是一个CSS3新的布 ...
- setBackgroundResource和setImageResource的区别
setBackgroundResource是设置view的背景图片 setImageResource是设置ImageView的图片 对于一个imagevewButton来说,你既可以setBackgr ...
- android 文件保存
将数据保存在外部存储器上 /* Checks if external storage is available for read and write */ public boolean isExter ...
- C# Json 序列化大全--任我行
public class JsonHelper { /// <summary> /// 将Model转换为Json字符串 /// </summary> /// <type ...
- android 摄像头相关使用记录
检测闪光灯是否存在 部分手机不存在闪光灯,检测是否存在还是有必要的. boolean hasFlash = this.getPackageManager().hasSystemFeature(Pack ...
- selenium自动化测试浏览器驱动安装(属于转载文章)
1.下载selenium压缩包 http://pypi.python.org/pypi/selenium 下载后压缩在python文件下的lib>site-package文件夹下 2.进入sel ...
- Python全栈工程师(函数嵌套、变量作用域)
ParisGabriel 感谢 大家的支持 每天坚持 一天一篇 点个订阅 ...
- mysql中查询常用的关键字
最简单的查询: 1 select * from [where ] 1 select column1,column2....from [where] 这里需要注意的是where子句中条件过滤使用到的关键 ...