zoukankan      html  css  js  c++  java
  • slave_exec_mode参数对主从复制的影响

    主从复制中常会遇到的问题就是1062主键重复、1032 slave上相关记录没找到

    如果在读写分离的架构中,slave同步失败会对业务造成很大的影响的(比如主写入了一条数据,从上无法读取到这样对业务影响很大)

    主从同步主要涉及一个参数: slave_exec_mode

    set global slave_exec_mode='IDEMPOTENT';  //幂等模式
    set global slave_exec_mode='STRICT';  //严格模式

     

    slave_exec_mode参数可用来自动处理同步复制错误:

    场景1: 

    # slave上执行
    > set global slave_exec_mode='IDEMPOTENT';  幂等模式 (默认是STRICT严格模式)
    > stop slave;
    > start slave;

    slave_exec_mode 主要是控制mysql 主从复制中 insert 出现 duplicate-key, update 出现 no-key-found  情况下的处理方式做控制。

     

    #idempotent(幂等) 模式影响:
     主机      备机
    insert     duplicate-key  slave 执行的是replace into 
    update  no-key-found   slave 不做任何处理


    场景2:

    #在slave上执行
    stop slave;
    set global slave_exec_mode=strict
    start slave;

    #stric(严格) 模式影响
     主机      备机
    insert    duplicate-key   slave  报duplicate-key errors
    update  no-key-found   slave 报no-key-found  error

  • 相关阅读:
    Ubuntu下 实现Linux与Windows的互相复制与粘贴
    bzoj2426
    bzoj1835
    bzoj1197
    bzoj1049
    bzoj2893
    bzoj1820
    bzoj1819
    bzoj1455
    bzoj3689
  • 原文地址:https://www.cnblogs.com/davygeek/p/7883305.html
Copyright © 2011-2022 走看看