sync_binlog
Controls how often the MySQL server synchronizes the binary log to disk.
sync_binlog=0: Disables synchronization of the binary log to disk by the MySQL server. Instead, the MySQL server relies on the operating system to flush the binary log to disk from time to time as it does for any other file. This setting provides the best performance, but in the event of a power failure or operating system crash, it is possible that the server has committed transactions that have not been synchronized to the binary log.
sync_binlog=0 时: 禁用MySQL server 将二进制日志同步到磁盘。 相反,Mysql server 依靠操作系统的方式将binary log 不时的持久化到磁盘,就像对其他文件一样。 此设置提供了最好的性能,但是在掉电,系统宕机的情况下,可能会有已提交但是未持久化到二进制日志的事务。
sync_binlog=1: Enables synchronization of the binary log to disk before transactions are committed. This is the safest setting but can have a negative impact on performance due to the increased number of disk writes. In the event of a power failure or operating system crash, transactions that are missing from the binary log are only in a prepared state. This permits the automatic recovery routine to roll back the transactions, which guarantees that no transaction is lost from the binary log.
sync_binlog=1 时:开启在事务提交前将binary log 同步到磁盘。 此种方式是对于数据库来说是最安全的,但是对数据性能有严重影响,因为增加了磁盘io。 在主机掉电或意外停机的情况下,事务还在prepared 状态。当机器重启后这些未提交的事务会回滚这样就防止丢事务的情况。
sync_binlog=N, where N is a value other than 0 or 1: The binary log is synchronized to disk after N binary log commit groups have been collected. In the event of a power failure or operating system crash, it is possible that the server has committed transactions that have not been flushed to the binary log. This setting can have a negative impact on performance due to the increased number of disk writes. A higher value improves performance, but with an increased risk of data loss.
sync_binlog=N 时: N是不同于0 和1 的值。 此种情况是收集N个提交了的binlog 再将数据持久到磁盘。这样会改善数据库的性能,但是当服务器宕机时这些未持久化到磁盘的事务有丢失的风险
For the greatest possible durability and consistency in a replication setup that uses InnoDB with transactions, use these settings:
sync_binlog=1.
innodb_flush_log_at_trx_commit=1.
对数据库持久化和一致性来讲需要将sync_binlog 和innodb_flush_log_at_trx_commit 同时设置为1。
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 recommended settings, 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. 参考文档:https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_sync_binlog
编辑推荐:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- sync_binlog
sync_binlog
26-03-01 - 如何在MySQL中实现替换字段部分内容
如何在MySQL中实现替换字段部分内容
26-03-01 - SAP管理软件系统优点概述
SAP管理软件系统优点概述
26-03-01 - 总结MySQL存储引擎MyISAM与InnoDB区别
总结MySQL存储引擎MyISAM与InnoDB区别
26-03-01 - MySQL基础运维——percona-toolkit运维工具
MySQL基础运维——percona-toolkit运维工具
26-03-01 - CentOS7系统下使用Mycat实现mysql读写分离部署
CentOS7系统下使用Mycat实现mysql读写分离部署
26-03-01 - 全面的MySQL基础运维知识点(三)
全面的MySQL基础运维知识点(三)
26-03-01 - 芯片和集成电路有什么关系
芯片和集成电路有什么关系
26-03-01 - 集成电路制造行业SAP系统软件特点
集成电路制造行业SAP系统软件特点
26-03-01 - 面试突击MySQL:高并发情况下,数据库该如何设计?
面试突击MySQL:高并发情况下,数据库该如何设计?
26-03-01
