加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

mysql关于redo事务日志ib_logfile的了解

发布时间:2022-04-06 11:45:02 所属栏目:MySql教程 来源:互联网
导读:mysql关于redo事务日志ib_logfile的理解: 1、redo事务日志就是ib_logfile,两个ib_logfile开头的文件,它们就是log group中的redo log file,而且它们的大小完全一致且等于变量innodb_log_file_size定义的值 2、redo事务日志的作用就是用于crash recovery
         mysql关于redo事务日志ib_logfile的理解:

1、redo事务日志就是ib_logfile,两个ib_logfile开头的文件,它们就是log group中的redo log file,而且它们的大小完全一致且等于变量innodb_log_file_size定义的值
 
2、redo事务日志的作用就是用于crash recovery,crash recovery是数据库重启时自动的行为,无需为DBA执行任何额外工作
 
3、MySQL以循环方式写入重做日志文件,如果最后1个 ib_logfile 被写满,而第一个ib_logfile中所有记录的事务对数据的变更已经被持久化到磁盘中,将清空并重用之。
 
4、redo事务日志的概念类似oracle的online redo log,里面包含commit和uncommit的数据
 
5、写redo事务日志有几种方式,每隔1秒或每次事务提交,所以里面可以包含没有提交uncommit的数据
 
6、show engine innodb status可以看到redo log的信息
 
       Log sequence number:表明当前redo log的最新LSN。
 
       Log flushed up to:表明当前已经刷新到磁盘上redo log的LSN。
 
      Last checkpoint at :redo log记录的更新已经刷新到磁盘上的检查点LSN,该LSN之前的redo log上记录的更新已全部刷新到磁盘上,可以被覆盖重复使用。
 
7、查看ib_logfile里的内容的方法
 
[root@mydb ~]# strings /var/lib/mysql/ib_logfile0
 
相关参数
 
innodb_log_file_size :每个redo log文件大小
 
innodb_log_files_in_group :redo log日志组成员个数
 
innodb_log_group_home_dir :redo log存放目录
 
innodb_page_size :InnoDB表空间的页面大小,默认16K
 
innodb_flush_log_at_timeout :日志刷新频率,单位秒
 
Write and flush the logs every N seconds. innodb_flush_log_at_timeout allows the timeout period between flushes to be increased in order to reduce flushing and avoid impacting performance of binary log group commit. The default setting for innodb_flush_log_at_timeout is once per second.
 
每N秒写入并刷新日志。 innodb_flush_log_at_timeout允许增加刷新之间的超时时间,以减少刷新并避免影响二进制日志组提交的性能。 innodb_flush_log_at_timeout的默认设置是每秒一次。
 
innodb_flush_log_at_trx_commit :控制commit动作是否刷新log buffer到磁盘
 
With a setting of 2, logs are written after each transaction commit and flushed to disk once per second
 
控制提交操作的严格ACID合规性与重新安排和批量完成与 提交 相关的I / O操作时可能实现的更高性能之间的平衡。
 
innodb_flush_log_at_timeout很多人误以为是控制innodb_flush_log_at_trx_commit值为0和2时的1秒频率,实际上并非如此。
 
以下四种方式将innodb日志缓冲区的日志刷新到磁盘
 
1、每秒一次执行刷新Innodb_log_buffer到重做日志文件。即使某个事务还没有提交,Innodb存储引擎仍然每秒会将重做日志缓存刷新到重做日志文件。
 
2、每个事务提交时会将重做日志刷新到重做日志文件。
 
3、当重做日志缓存可用空间少于一半时,重做日志缓存被刷新到重做日志文件
 
4、当有checkpoint时,checkpoint在一定程度上代表了刷到磁盘时日志所处的LSN位置
 
https://dev.mysql.com/doc/refman/5.7/en/innodb-redo-log.html
 
The redo log is a disk-based data structure used during crash recovery to correct data written by incomplete transactions.
 
重做日志是在崩溃恢复期间用于纠正由未完成事务写入的数据的基于磁盘的数据结构。
 
By default, the redo log is physically represented on disk as a set of files, named ib_logfile0 and ib_logfile1. MySQL writes to the redo log files in a circular fashion.
 
默认情况下,重做日志在磁盘上物理表示为一组文件,名为ib_logfile0和ib_logfile1。 MySQL以循环方式写入重做日志文件。
 
A disk-based data structure used during crash recovery, to correct data written by incomplete transactions. During normal operation, it encodes requests to change InnoDB table data, which result from SQL statements or low-level API calls through NoSQL interfaces. Modifications that did not finish updating the data files before an unexpected shutdown are replayed automatically.
 
The redo log is physically represented as a set of files, typically named ib_logfile0 and ib_logfile1. The data in the redo log is encoded in terms of records affected; this data is collectively referred to as redo. The passage of data through the redo logs is represented by the ever-increasing LSN value. The original 4GB limit on maximum size for the redo log is raised to 512GB in MySQL 5.6.3.
 
在崩溃恢复期间使用的基于磁盘的数据结构,用于纠正由未完成的事务写入的数据。 在正常操作期间,它编码更改InnoDB表数据的请求,这些数据来自SQL语句或通过NoSQL接口的低级API调用。 在意外关闭之前未完成更新数据文件的修改会自动重播。
 
重做日志在物理上表示为一组文件,通常名为ib_logfile0和ib_logfile1。 重做日志中的数据根据受影响的记录进行编码; 这些数据统称为重做。 数据通过重做日志的传递由不断增加的LSN值表示。 在MySQL 5.6.3中,重做日志的最大大小的原始4GB限制被提升到512GB。

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读