zoukankan      html  css  js  c++  java
  • mysql 从库落后主库太多优化

    有时候为了避免master.info和中继日志崩溃,在容忍额外的fsync()带来的开销,推荐设置
    sync_master_info = 1
    sync_relay_log = 1
    sync_relay_log_info = 1

    当然,如果备库跟主库延迟特别大,备库的io线程谢了很多中继日志,通过relay_log_purge设置,sql线程重放完一个中继日志中的事件后会尽快将删除。
    极端情况下,需要设置relay_log_space_limit,这样如果中继日志的大小超过这个值,I/O线程将停止,等待sql线程释放磁盘空间。

    sync_master_info:每间隔多少事务刷新master.info,如果是table(innodb)设置无效,每个事务都会更新
        The effects of this variable on a replication slave depend on whether the slave's master_info_repository is set to FILE or TABLE
    sync_relay_log:默认为10000,即每10000次sync_relay_log事件会刷新到磁盘。为0则表示不刷新,交由OS的cache控制
        If the value of this variable is greater than 0, the MySQL server synchronizes its relay log to disk (using fdatasync()) after every sync_relay_log events are written to the relay log. Setting this variable takes effect for all replication channels immediately, including running channels
    sync_relay_log_info:每间隔多少事务刷新relay-log.info,如果是table(innodb)设置无效,每个事务都会更新
    master_info_repository:记录主库binlog的信息,可以设置FILE(master.info)或者TABLE(mysql.slave_master_info)
    relay_log_info_repository:记录备库relaylog的信息,可以设置FILE(relay-log.info)或者TABLE(mysql.slave_relay_log_info)

    为了快速让从库同步主库最新数据,可临时修改以下配置:

    innodb_flush_log_at_trx_commit = 0

    sync_binlog = 0

    sync_master_info = 2000
    sync_relay_log = 2000
    sync_relay_log_info = 2000

  • 相关阅读:
    CodeSmith注册错误的解决方法
    我是“坚守者”还是"背叛者"?
    拿什么留住你,我的程序员
    去除HTML代码得函数
    页面之间传递参数得几种方法
    nhibernate source code analyzed (abstract classes in nhibernate2.0)
    Web 2.0时代RSS的.Net实现
    Visual Studio.net 2003安装提示重启问题
    开放思路,综合考虑,心胸开阔,做一个合格的项目经理
    了解实际开发中 Hashtable 的特性原理 .NET, JAVA, PHP
  • 原文地址:https://www.cnblogs.com/lvcisco/p/9272860.html
Copyright © 2011-2022 走看看