mysql中的binlog是什么?
我已经设置了mysql参数innodb_flush_log_at_trx_commit=0。这意味着mysql每秒将事务刷新到HDD 1次。如果 mysql 因这次刷新而失败(因为断电),我是否会丢失这些事务中的数据,这是真的吗?或者mysql会在每次事务后将它们保存在数据文件(ibdata1)中,而不管binlog刷新如何?
谢谢。
I've set mysql parameter innodb_flush_log_at_trx_commit=0. It means that mysql flushes transactions to HDD 1 time per second. Is it true that if mysql will fail with this flush (because of power off) i will lose my data from these transactions. Or mysql will save them in data file (ibdata1) after each transaction regardless of binlog flush?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
二进制日志包含描述数据库更改的“事件”,例如表创建操作或表数据更改。它还包含可能进行更改的语句的事件(例如,没有匹配任何行的 DELETE),除非使用基于行的日志记录。二进制日志还包含有关每个语句更新数据所需时间的信息。二进制日志有两个重要用途:
二进制日志不用于不修改数据的 SELECT 或 SHOW 等语句。
https://dev.mysql.com/doc/refman/8.0 /en/binary-log.html
The binary log contains “events” that describe database changes such as table creation operations or changes to table data. It also contains events for statements that potentially could have made changes (for example, a DELETE which matched no rows), unless row-based logging is used. The binary log also contains information about how long each statement took that updated data. The binary log has two important purposes:
The binary log is not used for statements such as SELECT or SHOW that do not modify data.
https://dev.mysql.com/doc/refman/8.0/en/binary-log.html
这里是MySQL参考中的条目innodb_flush_log_at_trx_commit 手册。如果该值设置为 0,则可能会丢失最后一秒的事务。
请注意,binlog 实际上是不同的东西,它独立于 innodb,并且用于所有存储引擎。 这里是MySQL 参考手册。
Here is the entry in the MySQL reference manual for innodb_flush_log_at_trx_commit. You can lose the last second of transactions with the value set to 0.
Note that the binlog is actually something different that is independent of innodb and is used for all storage engines. Here is the chapter on the binary log in the MySQL reference manual.