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

  • 相关阅读:
    GetAwaiter和GetResult
    Sql中的小数点和保留位数
    简单工厂类
    c#种GetType()和TypeOf()的区别
    php 内置正则配置邮箱
    通过手机号获取定位
    使用navicat连接mysql 报错:2003-Can't comment to Mysql server on '192.168.X.X'(10038)
    java基础系列(七):内部类的详解
    bootstrap : 响应式导航
    CSS
  • 原文地址:https://www.cnblogs.com/davygeek/p/7883305.html
Copyright © 2011-2022 走看看