mysql中的binlog是什么?

发布于 2024-08-03 19:32:28 字数 183 浏览 4 评论 0原文

我已经设置了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱你不解释 2024-08-10 19:32:28

二进制日志包含描述数据库更改的“事件”,例如表创建操作或表数据更改。它还包含可能进行更改的语句的事件(例如,没有匹配任何行的 DELETE),除非使用基于行的日志记录。二进制日志还包含有关每个语句更新数据所需时间的信息。二进制日志有两个重要用途:

  1. 对于复制,主复制服务器上的二进制日志提供要发送到辅助服务器的数据更改的记录。主服务器将其二进制日志中包含的事件发送到其辅助服务器,辅助服务器执行这些事件以进行与主服务器上所做的相同的数据更改。
  2. 某些数据恢复操作需要使用二进制日志。恢复备份后,将重新执行备份后记录的二进制日志中的事件。这些事件使数据库从备份点起保持最新状态。

二进制日志不用于不修改数据的 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:

  1. For replication, the binary log on a primary replication server provides a record of the data changes to be sent to secondary servers. The primary server sends the events contained in its binary log to its secondaries, which execute those events to make the same data changes that were made on the primary.
  2. Certain data recovery operations require the use of the binary log. After a backup has been restored, the events in the binary log that were recorded after the backup was made are re-executed. These events bring databases up to date from the point of the backup

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

晨光如昨 2024-08-10 19:32:28

这里是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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文