sync_binlog
发表于:2025-11-11 作者:千家信息网编辑
千家信息网最后更新 2025年11月11日,5.6默认值0,到了5.7默认是1sync_binlogCommand-Line Format--sync-binlog=#System VariableNamesync_binlogVariable
千家信息网最后更新 2025年11月11日sync_binlog5.6默认值0,到了5.7默认是1
sync_binlog=1 or N This makes MySQL synchronize the binary log's contents to disk each time it commits a transaction 默认情况下,并不是每次写入时都将binlog与硬盘同步。因此如果操作系统或机器(不仅仅是MySQL服务器)崩溃,有可能binlog中最后的语句丢 失了。要想防止这种情况,你可以使用sync_binlog全局变量(1是最安全的值,但也是最慢的),使binlog在每N次binlog写入后与硬盘 同步。即使sync_binlog设置为1,出现崩溃时,也有可能表内容和binlog内容之间存在不一致性。如果使用InnoDB表,MySQL服务器 处理COMMIT语句,它将整个事务写入binlog并将事务提交到InnoDB中。如果在两次操作之间出现崩溃,重启时,事务被InnoDB回滚,但仍 然存在binlog中。可以用--innodb-safe-binlog选项来增加InnoDB表内容和binlog之间的一致性。(注释:在MySQL 5.1中不需要--innodb-safe-binlog;由于引入了XA事务支持,该选项作废了),该选项可以提供更大程度的安全,使每个事务的 binlog(sync_binlog =1)和(默认情况为真)InnoDB日志与硬盘同步,该选项的效果是崩溃后重启时,在滚回事务后,MySQL服务器从binlog剪切回滚的 InnoDB事务。这样可以确保binlog反馈InnoDB表的确切数据等,并使从服务器保持与主服务器保持同步(不接收 回滚的语句)。
sync_binlog
| Command-Line Format | --sync-binlog=# | ||
| System Variable | Name | sync_binlog | |
| Variable Scope | Global | ||
| Dynamic Variable | Yes | ||
| Permitted Values (32-bit platforms) | Type | integer | |
| Default | 0 | ||
| Min Value | 0 | ||
| Max Value | 4294967295 | ||
| Permitted Values (64-bit platforms) | Type | integer | |
| Default | 0 | ||
| Min Value | 0 | ||
| Max Value | 4294967295 | ||
If the value of this variable is greater than 0, the MySQL server synchronizes its binary log to disk (using fdatasync()) after sync_binlog commit groups are written to the binary log. The default value of sync_binlog is 0, which does no synchronizing to disk-in this case, the server relies on the operating system to flush the binary log's contents from time to time as for any other file. A value of 1 is the safest choice because in the event of a crash you lose at most one commit group from the binary log. However, it is also the slowest choice (unless the disk has a battery-backed cache, which makes synchronization very fast).
百度翻译:如果这个变量的值大于0,MySQL服务器同步二进制日志到磁盘(使用fdatasync())后sync_binlog犯组写入二进制日志。sync_binlog的默认值是0,并没有同步在这种情况下,磁盘,服务器依赖于操作系统的二进制日志的内容刷新时间为任何其他文件。一个1的值是最安全的选择,因为在一个崩溃的事件,你失去了最一个提交组从二进制日志。然而,它也是最慢的选择(除非磁盘具有电池备份的高速缓存,这使得同步非常快)。sync_binlog=1 or N This makes MySQL synchronize the binary log's contents to disk each time it commits a transaction 默认情况下,并不是每次写入时都将binlog与硬盘同步。因此如果操作系统或机器(不仅仅是MySQL服务器)崩溃,有可能binlog中最后的语句丢 失了。要想防止这种情况,你可以使用sync_binlog全局变量(1是最安全的值,但也是最慢的),使binlog在每N次binlog写入后与硬盘 同步。即使sync_binlog设置为1,出现崩溃时,也有可能表内容和binlog内容之间存在不一致性。如果使用InnoDB表,MySQL服务器 处理COMMIT语句,它将整个事务写入binlog并将事务提交到InnoDB中。如果在两次操作之间出现崩溃,重启时,事务被InnoDB回滚,但仍 然存在binlog中。可以用--innodb-safe-binlog选项来增加InnoDB表内容和binlog之间的一致性。(注释:在MySQL 5.1中不需要--innodb-safe-binlog;由于引入了XA事务支持,该选项作废了),该选项可以提供更大程度的安全,使每个事务的 binlog(sync_binlog =1)和(默认情况为真)InnoDB日志与硬盘同步,该选项的效果是崩溃后重启时,在滚回事务后,MySQL服务器从binlog剪切回滚的 InnoDB事务。这样可以确保binlog反馈InnoDB表的确切数据等,并使从服务器保持与主服务器保持同步(不接收 回滚的语句)。
事务
服务器
同步
服务
日志
内容
情况
安全
之间
二进制
硬盘
磁盘
语句
操作系统
变量
系统
选择
一致
一致性
不一致性
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全 普法宣传
服务器远程管理卡ip
如何用数据库bak
固原分销系统软件开发
java软件开发助理好
郑州医院信息化软件开发公司
web服务器常见的安全威胁
amd服务器关闭超线程
盖斯服务器
数据库中的约束除了主码还有什么
如何切换到其他服务器
jdbc路径怎么连接数据库
数据库中的逻辑结构的定义
将新建表挂在数据库用户下
临夏网络安全
阿里云数据库恢复吗
双阳区什么是网络安全创新服务
荔湾软件开发专业
进一步深化网络安全管理
网络安全法研究方向
什么软件备份应用程序数据库
乌镇互联网大会绿盟科技
mc国际版小游戏服务器地址
加拿大vox高防服务器
科技互联网老员工
看网络安全教育有感
泉州数据库培训学费
软件开发申请实名认证
正胃胶囊药品广告数据库
国家安全体系网络安全