MySql InnoDB中的redo log和doublewirte buffer有什么区别?
What is the difference between redo log and doublewirte buffer in MySql InnoDB?
之前,我以为redo log是用来在crash时恢复数据库的。
但是当我看到注释如下时,我觉得我错了:
crash recovery
The cleanup activities that occur when MySQL is started again after a crash. For InnoDB tables, changes from
incomplete transactions are replayed using data from the redo log. Changes that were committed before the
crash, but not yet written into the data files, are reconstructed from the doublewrite buffer. When the database is
shut down normally, this type of activity is performed during shutdown by the purge operation.
During normal operation, committed data can be stored in the change buffer for a period of time before being
written to the data files. There is always a tradeoff between keeping the data files up-to-date, which introduces
performance overhead during normal operation, and buffering the data, which can make shutdown and crash
recovery take longer.
See Also change buffer, commit, crash, data files, doublewrite buffer, InnoDB, purge, redo log.
it is from mysql refman-5.7-en.pdf.
如果是真的,不知道redo log有什么用。因为,当崩溃发生时,mysql 可以通过双写缓冲区自行恢复。看来重做日志没有意义。也许我忽略了什么地方,但我不知道。
我想知道它们之间的区别以及重做日志对 mysql InnoDB 是否重要?
这个博客 post 可能会回答您的问题:
点击here
重做日志似乎在较低的更关键级别运行。我使用 mySQL 作为桌面分析工具,所以我认为我不需要生产数据库保护。当双写缓冲关闭 (innodb-doublewrite=0
) 时,我发现查询性能明显提高。没问题,一年多了。重做日志是另一回事。在禁用它的一周内,我最终需要重建我的数据库。
在 8.0.21 中,引入了切换重做日志 (ALTER INSTANCE ENABLE|DISABLE REDO_LOG
) 的功能。 “为什么不试一试呢?”我想。关闭后,我发现加载速度提高了 2-5%。
这在加载大文件时会有所不同,特别是如果使用 Parallel Table Import Utility(在 8.0.17 中引入)。
不幸的是,我禁用了 REDO LOG,并且在我写入 tables 时在我的工作站上遇到了一个小问题,并以这个错误消息结束:
[ERROR] [MY-013578] [InnoDB] Server was killed when Innodb Redo logging was disabled. Data files could be corrupt. You can try to restart the database with innodb_force_recovery=6
我必须初始化一个新实例,因为 table 中的 none 会让我在收到此错误后写任何东西。
Force_recovery=6
是严格的,read-only。我不得不重建我的数据库(我每次导入 tables 时都会这样做),但是一些 tables 的常量和历史我必须手动恢复。
This is documented on the mySQL page Redo Log documentation page. 重做日志上的警告带有阴影粗体警告标注。我应该听听的。
我仍然禁用重做日志,但仅从运行并行导入实用程序的 .js 代码内部禁用:
\sql
SET GLOBAL local_infile = 1;
ALTER INSTANCE DISABLE INNODB REDO_LOG;
我总是在代码中启用它。我关闭双写缓冲区,因为任何呈现部分的事务我都可以通过重新加载 table.
轻松更正
之前,我以为redo log是用来在crash时恢复数据库的。 但是当我看到注释如下时,我觉得我错了:
crash recovery
The cleanup activities that occur when MySQL is started again after a crash. For InnoDB tables, changes from incomplete transactions are replayed using data from the redo log. Changes that were committed before the crash, but not yet written into the data files, are reconstructed from the doublewrite buffer. When the database is shut down normally, this type of activity is performed during shutdown by the purge operation.
During normal operation, committed data can be stored in the change buffer for a period of time before being written to the data files. There is always a tradeoff between keeping the data files up-to-date, which introduces performance overhead during normal operation, and buffering the data, which can make shutdown and crash recovery take longer. See Also change buffer, commit, crash, data files, doublewrite buffer, InnoDB, purge, redo log.
it is from mysql refman-5.7-en.pdf.
如果是真的,不知道redo log有什么用。因为,当崩溃发生时,mysql 可以通过双写缓冲区自行恢复。看来重做日志没有意义。也许我忽略了什么地方,但我不知道。
我想知道它们之间的区别以及重做日志对 mysql InnoDB 是否重要?
这个博客 post 可能会回答您的问题:
点击here
重做日志似乎在较低的更关键级别运行。我使用 mySQL 作为桌面分析工具,所以我认为我不需要生产数据库保护。当双写缓冲关闭 (innodb-doublewrite=0
) 时,我发现查询性能明显提高。没问题,一年多了。重做日志是另一回事。在禁用它的一周内,我最终需要重建我的数据库。
在 8.0.21 中,引入了切换重做日志 (ALTER INSTANCE ENABLE|DISABLE REDO_LOG
) 的功能。 “为什么不试一试呢?”我想。关闭后,我发现加载速度提高了 2-5%。
这在加载大文件时会有所不同,特别是如果使用 Parallel Table Import Utility(在 8.0.17 中引入)。
不幸的是,我禁用了 REDO LOG,并且在我写入 tables 时在我的工作站上遇到了一个小问题,并以这个错误消息结束:
[ERROR] [MY-013578] [InnoDB] Server was killed when Innodb Redo logging was disabled. Data files could be corrupt. You can try to restart the database with innodb_force_recovery=6
我必须初始化一个新实例,因为 table 中的 none 会让我在收到此错误后写任何东西。
Force_recovery=6
是严格的,read-only。我不得不重建我的数据库(我每次导入 tables 时都会这样做),但是一些 tables 的常量和历史我必须手动恢复。
This is documented on the mySQL page Redo Log documentation page. 重做日志上的警告带有阴影粗体警告标注。我应该听听的。
我仍然禁用重做日志,但仅从运行并行导入实用程序的 .js 代码内部禁用:
\sql
SET GLOBAL local_infile = 1;
ALTER INSTANCE DISABLE INNODB REDO_LOG;
我总是在代码中启用它。我关闭双写缓冲区,因为任何呈现部分的事务我都可以通过重新加载 table.
轻松更正