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

  • 相关阅读:
    常用正则表达式
    The Skins Factory 界面设计欣赏
    The Regulator 轻松上手
    Visual C#的Web XML编程
    业务流程不是需求
    如使用ODBC连接informix
    AJAX在信息系统中的应用研究
    浅谈几个SQL的日志概念
    量产 朗科(Netac)朗盛系列闪存盘E108 8G 手记
    【转】告诉大家他们是怎么成为富翁的
  • 原文地址:https://www.cnblogs.com/lvcisco/p/9272860.html
Copyright © 2011-2022 走看看