mysql从库可以有多个主库吗_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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值