mysql参数innodb_flush_log_at_trx_commit

查看mysql数据库innodb_flush_log_at_trx_commit :

mysql>  SHOW GLOBAL VARIABLES LIKE ‘innodb_flush_log%‘;
+--------------------------------+-------+
| Variable_name                  | Value |
+--------------------------------+-------+
| innodb_flush_log_at_timeout    | 1     |
| innodb_flush_log_at_trx_commit | 1     |
+--------------------------------+-------+
2 rows in set (0.00 sec)

mysql> 

参考资料:https://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit

innodb_flush_log_at_trx_commit

Command-Line Format --innodb-flush-log-at-trx-commit[=#]
System Variable Name innodb_flush_log_at_trx_commit
Variable Scope Global
Dynamic Variable Yes
Permitted Values Type enumeration
Default 1
Valid Values 0
1
2

Controls the balance between strict ACID compliance for commit operations and higher performance that is possible when commit-related I/O operations are rearranged and done in batches. You can achieve better performance by changing the default value but then you can lose up to a second of transactions in a crash.

  • The default value of 1 is required for full ACID compliance. With this value, the contents of the InnoDB log buffer are written out to the log file at each transaction commit and the log file is flushed to disk.
  • With a value of 0, the contents of the InnoDB log buffer are written to the log file approximately once per second and the log file is flushed to disk. No writes from the log buffer to the log file are performed at transaction commit. Once-per-second flushing is not guaranteed to happen every second due to process scheduling issues. Because the flush to disk operation only occurs approximately once per second, you can lose up to a second of transactions with any mysqld process crash.
  • With a value of 2, the contents of the InnoDB log buffer are written to the log file after each transaction commit and the log file is flushed to disk approximately once per second. Once-per-second flushing is not 100% guaranteed to happen every second, due to process scheduling issues. Because the flush to disk operation only occurs approximately once per second, you can lose up to a second of transactions in an operating system crash or a power outage.
  • InnoDB log flushing frequency is controlled by innodb_flush_log_at_timeout, which allows you to set log flushing frequency to N seconds (where N is 1 ... 2700, with a default value of 1). However, any mysqld process crash can erase up to N seconds of transactions.
  • DDL changes and other internal InnoDB activities flush the InnoDB log independent of the innodb_flush_log_at_trx_commit setting.
  • InnoDB crash recovery works regardless of the innodb_flush_log_at_trx_commit setting. Transactions are either applied entirely or erased entirely.

For durability and consistency in a replication setup that uses InnoDB with transactions:

  • If binary logging is enabled, set sync_binlog=1.
  • Always set innodb_flush_log_at_trx_commit=1.

Caution

Many operating systems and some disk hardware fool the flush-to-disk operation. They may tell mysqld that the flush has taken place, even though it has not. In this case, the durability of transactions is not guaranteed even with the setting 1, and in the worst case, a power outage can corrupt InnoDB data. Using a battery-backed disk cache in the SCSI disk controller or in the disk itself speeds up file flushes, and makes the operation safer. You can also try to disable the caching of disk writes in hardware caches.

命令查看:mysqld --verbose --help

可通过命令设置,也可通过my.cnf配置.

--innodb-flush-log-at-trx-commit[=#]
                      Set to 0 (write and flush once per second), 1 (write and
                      flush at each commit) or 2 (write at commit, flush once
                      per second).
时间: 2024-10-07 21:40:50

mysql参数innodb_flush_log_at_trx_commit的相关文章

mysql 参数 innodb_flush_log_at_trx_commit

问题,项目后台有一个定时任务,需要跑一批数据,跑完后存入到一个表里,用来做信息查询,数据大,逻辑复杂,耗时,多线程处理数据? 解答:以为程序的问题,把所有的关键点步骤都加上了日志,拿开发环境的日志看,一点没毛病,后来排查到Mysql,是不是服务器挂了,通过命令来查看,确实没有挂,是不是项目过载,也挂了,也没有,最后想起来,mysql可能不是实时刷入磁盘的,所有像运维拿到了my.cnf配置文件,果然是一个参数问题.运维让插入数据度快,innodb_flush_log_at_trx_commit 这

mysql参数安全设置

MySQL安全相关的参数有哪些?该如何配置? 1.MySQL数据安全 innodb_flush_log_at_trx_commit =1 #innodb每次提交事务redo buffer 刷新到redo log innodb_doublewrite =on #开启innodb特性"二次写" secure_file_priv=null  #禁用导入导出目录,避免被人利用 2.复制安装 sync_binlog = 1  #事务每次提交binlog cache刷新到binlog file b

MySQL参数DELAY_KEY_WRITE的详细说明

caseUNDOATTENTION: { FriendInfo *info = [dataArray objectAtIndex:0]; [self.managerattentionList:_pageIndexoneRecord:YESotherId:-100]; [self.dataArray removeObject:info]; self.isOneRecord = YES; break; } case ATTENTIONLIST: { _hasMore = state.hasMore;

MySQL参数文件及参数修改方法

MySQL参数文件: MySQL数据库初始化参数由参数文件来设置,如果没有设置参数文件,mysql就按照系统中参数的默认值来启动. 在windows和linux上,参数文件可以被放在多个位置,数据库启动时按照不同的顺序来搜索,如果多个位置都有参数文件,则搜索顺序靠后的参数文件中的参数将覆盖前的参数. Windows上参数文件读取顺序 Linux上参数文件读取顺序 修改mysql参数的方法:

PHP - PDO 之 mysql 参数绑定

<?php /* pdo 学习 */ $dsn = 'mysql:host=localhost;dbname=cswl';//构建连接dsn $db = new pdo($dsn,'root','');//实例化pdo[第二个参数是用户名,第三个为密码] #.查询 $obj = $db->prepare("select * from level_class where id = ?"); $id = 28; $obj->bindParam(1,$id,PDO::PAR

mysql参数优化辅助工具之mysqltuner

Mysqltuner.sql 的使用和安装. Mysqltuner 是一个mysql参数优化辅助工具,它可以对mysql进行全面的体检,然后给出针对性的体检报告 1.mysqltuner 下载 mysqltuner 官网:http://mysqltuner.com/ 可以下载最新版本的. 2.mysqltuner 的安装和使用. Mysqltuner  就是一套perl脚本,不需要任何的安装,将下载下来的tar安装包解压下就行了. [[email protected] software]# ta

MySQL参数:innodb_flush_log_at_trx_commit 和 sync_binlog

innodb_flush_log_at_trx_commit 和 sync_binlog 是 MySQL 的两个配置参数,前者是 InnoDB 引擎特有的.之所以把这两个参数放在一起讨论,是因为在实际应用中,它们的配置对于 MySQL 的性能有很大影响. 1. innodb_flush_log_at_trx_commit 简而言之,innodb_flush_log_at_trx_commit 参数指定了 InnoDB 在事务提交后的日志写入频率.这么说其实并不严谨,且看其不同取值的意义和表现.

MySQL 重要参数 innodb_flush_log_at_trx_commit 和 sync_binlog

innodb_flush_log_at_trx_commit 该参数控制重做日志写入磁盘的过程.我们知道 InnoDB 使用"Write Ahead Log"策略来避免数据丢失问题,即依靠重做日志来保证数据能在丢失后进行恢复.因此,InnoDB 重做日志的持久化非常重要.这个参数的默认值为1 首先需要大致了解一下mysql日志操作步骤: log_buff --> mysql写 (write) --> log_file --> OS刷新 (flush) --> d

MySQL参数调优最佳实践

前言很多时候,RDS用户经常会问如何调优RDS MySQL的参数,为了回答这个问题,写一篇blog来进行解释: 哪一些参数不能修改,那一些参数可以修改:这些提供修改的参数是不是已经是最佳设置,如何才能利用好这些参数:哪些参数可以改细心的用户在购买RDS的时候都会看到,不同规格能够提供的最大连接数以及内存是不同的,所以这一些产品规格的限制参数:连接数.内存用户是不能够修改的,如果内存或者连接数出现了瓶颈: 内存瓶颈:实例会出现OOM,然后导致主备发生切换连接数瓶颈:应用不能新建立连接到数据库则需要