zoukankan      html  css  js  c++  java
  • mysql复制过滤参数说明

    参考文档:
     
    总共有6个过滤规则:
    1  --replicate-do-db
    2  --replicate-ignore-db
    3  --replicate-do-table
    4  --replicate-wild-do-table
    5  --replicate-ignore-table
    6  --replicate-wild-ignore-table
     
    以上6个规则的前2个是库级别的规则,后4个是表级别的规则。使用注意点:
    1:库级别的规则,只针对binlog_format='STATEMENT'或'MIXED'。
    2:如果是binlog_format='ROW',不受库级别规则限制,只受表级别规则限制。
    3:表级别的规则,针对所有模式。
    4:binlog_format='STATEMENT'或者'MIXED'时,记录use 语句,此时如果使用 --replicate-do-db,则不支持跨库修改。
        如use test; update db1 set …… 这里判断的是use 后面的test库,所以updte语句不执行。建议使用--replicate-wild-do-table
    5:binlog_format='ROW'时,不记录use语句。只受表级别规则的影响。只能配置后面四条规则。
     
    测试不同模式下binlog记录情况:
     
    执行sql:
    set global binlog_format='row';
    use test;
    update db1.t2 set name='a200' where id=105;
    use db1;
     
    记录的binlog如下:
     1 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
     2 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
     3 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
     4 DELIMITER /*!*/;
     5 # at 4
     6 #170808  0:49:08 server id 1882073306  end_log_pos 120 CRC32 0xbddf73ce         Start: binlog v 4, server v 5.6.23-72.1-log created 170808  0:49:08
     7 # Warning: this binlog is either in use or was not closed properly.
     8 # at 120
     9 #170808  0:50:16 server id 1882073306  end_log_pos 191 CRC32 0xb2586cef         Query   thread_id=73    exec_time=0     error_code=0
    10 SET TIMESTAMP=1502124616/*!*/;
    11 SET @@session.pseudo_thread_id=73/*!*/;
    12 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
    13 SET @@session.sql_mode=1073741824/*!*/;
    14 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
    15 /*!C utf8 *//*!*/;
    16 SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
    17 SET @@session.lc_time_names=0/*!*/;
    18 SET @@session.collation_database=DEFAULT/*!*/;
    19 BEGIN
    20 /*!*/;
    21 # at 191
    22 #170808  0:50:16 server id 1882073306  end_log_pos 245 CRC32 0xe7585ab8         Table_map: `db1`.`t2` mapped to number 395
    23 # at 245
    24 #170808  0:50:16 server id 1882073306  end_log_pos 365 CRC32 0x86dbbb24         Update_rows: table id 395 flags: STMT_END_F
    25 ### UPDATE `db1`.`t2`
    26 ### WHERE
    27 ###   @1=105 /* INT meta=0 nullable=0 is_null=0 */
    28 ###   @2='a100' /* VARSTRING(90) meta=90 nullable=0 is_null=0 */
    29 ###   @3='57747ab889255af96b48d65e505382' /* VARSTRING(90) meta=90 nullable=0 is_null=0 */
    30 ###   @4='' /* VARSTRING(72) meta=72 nullable=0 is_null=0 */
    31 ###   @5=NULL /* VARSTRING(72) meta=0 nullable=1 is_null=1 */
    32 ### SET
    33 ###   @1=105 /* INT meta=0 nullable=0 is_null=0 */
    34 ###   @2='a200' /* VARSTRING(90) meta=90 nullable=0 is_null=0 */
    35 ###   @3='57747ab889255af96b48d65e505382' /* VARSTRING(90) meta=90 nullable=0 is_null=0 */
    36 ###   @4='' /* VARSTRING(72) meta=72 nullable=0 is_null=0 */
    37 ###   @5=NULL /* VARSTRING(72) meta=0 nullable=1 is_null=1 */
    38 # at 365
    39 #170808  0:50:16 server id 1882073306  end_log_pos 396 CRC32 0x99f0e5d3         Xid = 32212
    40 COMMIT/*!*/;
     
    执行sql:
    set global binlog_format='mixed';
    use test;
    update db1.t2 set name='a300' where id=105;
    use db1;
     
    记录的binlog如下:
     1 # at 396
     2 #170808  0:53:14 server id 1882073306  end_log_pos 474 CRC32 0x46f75d21         Query   thread_id=74    exec_time=0     error_code=0
     3 SET TIMESTAMP=1502124794/*!*/;
     4 BEGIN
     5 /*!*/;
     6 # at 474
     7 #170808  0:53:14 server id 1882073306  end_log_pos 589 CRC32 0x7193484c         Query   thread_id=74    exec_time=0     error_code=0
     8 use `test`/*!*/;
     9 SET TIMESTAMP=1502124794/*!*/;
    10 update db1.t2 set name='a300' where id=105
    11 /*!*/;
    12 # at 589
    13 #170808  0:53:14 server id 1882073306  end_log_pos 620 CRC32 0xc3e0c9e3         Xid = 32328
    14 COMMIT/*!*/;
    15 DELIMITER ;
    16 # End of log file
    17 ROLLBACK /* added by mysqlbinlog */;
    18 /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
    19 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
  • 相关阅读:
    API网络数据安全
    【值得收藏】一文掌握用户画像系统构建全流程
    手把手教你从0到1学会tensorflow进行模型训练,并能在网页轻松运行
    APP选择第三方消息推送平台时,有哪些需要关注的重要性能指标?
    如何防薅羊毛?个推基于大数据风控引擎助力APP反欺诈!
    微信为什么要搞一个小游戏?
    关于 JS 模块化的最佳实践总结
    张小龙2019微信公开课15个看点总结
    编程:从前有一个傻呆程序员,老婆交给他一项任务,他办了四次才满意
    JS是如何计算 1+1=2 的?
  • 原文地址:https://www.cnblogs.com/jerry-rock/p/7380836.html
Copyright © 2011-2022 走看看