zoukankan      html  css  js  c++  java
  • MySQL binlog_rows_query_log_events在线设置无效

    binlog_rows_query_log_events 对binlog_format=row有效,设为true后可以在binary log中记录原始的语句

    官方文档显示binlog_rows_query_log_events是动态参数,可以在线设置生效,但是测试中发现只有重启才可以生效

    版本信息

    22:25:13[test](;)> select version();
    +------------+
    | version()  |
    +------------+
    | 5.7.10-log |
    +------------+
    
    [root@mysql-bcc03 3309_test]# mysqlbinlog --version
    mysqlbinlog Ver 3.4 for linux-glibc2.5 at x86_64

    在线变更测试

    22:22:32[test](;)> set global binlog_rows_query_log_events=1;
    Query OK, 0 rows affected (0.00 sec)
    
    22:24:59[test](;)> update t6 set id=3 where id =2;
    
    # mysqlbinlog -v -v  mysql-bin.000002 --base64-output='decode-rows'
    /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
    /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
    DELIMITER /*!*/;
    # at 4
    #171113 22:13:35 server id 10211192  end_log_pos 123 CRC32 0x106f7540   Start: binlog v 4, server v 5.7.10-log created 171113 22:13:35
    # at 123
    #171113 22:13:35 server id 10211192  end_log_pos 154 CRC32 0xdb6b8ed7   Previous-GTIDs
    # [empty]
    # at 154
    #171113 22:13:48 server id 10211192  end_log_pos 219 CRC32 0x837c9303   GTID    last_committed=0        sequence_number=1
    SET @@SESSION.GTID_NEXT= '95bd577a-5fbd-11e7-ab42-fa163eef641d:1'/*!*/;
    # at 219
    #171113 22:13:48 server id 10211192  end_log_pos 291 CRC32 0x7cffa554   Query   thread_id=6982929       exec_time=0     error_code=0
    SET TIMESTAMP=1510582428/*!*/;
    SET @@session.pseudo_thread_id=6982929/*!*/;
    SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
    SET @@session.sql_mode=1344798720/*!*/;
    SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
    /*!C utf8 *//*!*/;
    SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
    SET @@session.lc_time_names=0/*!*/;
    SET @@session.collation_database=DEFAULT/*!*/;
    BEGIN
    /*!*/;
    # at 291
    #171113 22:13:48 server id 10211192  end_log_pos 336 CRC32 0x73164254   Table_map: `test`.`t6` mapped to number 8329
    # at 336
    #171113 22:13:48 server id 10211192  end_log_pos 512 CRC32 0xddf3d784   Update_rows: table id 8329 flags: STMT_END_F
    ### UPDATE `test`.`t6`
    ### WHERE
    ###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
    ### SET
    ###   @1=3 /* INT meta=0 nullable=1 is_null=0 */

     binlog中显示# [empty]   正常应该是原始语句

    测试重启再配置文件中添加global binlog_rows_query_log_events=1,执行同样的操作查看binlog

    BEGIN
    /*!*/;
    # at 776
    #171113 22:22:32 server id 10211192  end_log_pos 835 CRC32 0xc7f76055   Rows_query
    # update t6 set id=1 where id is null
    # at 835
    #171113 22:22:32 server id 10211192  end_log_pos 880 CRC32 0x96cc634f   Table_map: `test`.`t6` mapped to number 133
    # at 880
    #171113 22:22:32 server id 10211192  end_log_pos 922 CRC32 0x68f485cf   Update_rows: table id 133 flags: STMT_END_F
    ### UPDATE `test`.`t6`
    ### WHERE
    ###   @1=NULL /* INT meta=0 nullable=1 is_null=1 */
    ### SET
    ###   @1=1 /* INT meta=0 nullable=1 is_null=0 */

    总结就是需要重启才可生效(不知道是否是自己遗漏了什么)

  • 相关阅读:
    学习使用GitHub托管团队代码开展协作
    实验一 GIT 代码版本管理
    实验五 单元测试
    实验二 结对编程(阶段二)
    结对编程 第一阶段
    实验一 GIT代码版本管理
    实验五 单元测试
    实验二 结对编程(第二阶段)
    结对编程 第一阶段报告
    实验一 GIT代码版本管理
  • 原文地址:https://www.cnblogs.com/Bccd/p/7828663.html
Copyright © 2011-2022 走看看