关于前端:syncbinlo主从复制

8次阅读

共计 2248 个字符,预计需要花费 6 分钟才能阅读完成。

sync_binlog

Controls how often the MySQL server synchronizes the binary log to disk.

sync_binlog=0: Disables syncwww.diuxie.comhronization 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 去同步 binary log 到磁盘。依附操作系统的形式将 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 prpared 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。

Caution
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.

正文完
 0