mysql參數sql_log_bin配置


mysql參數sql_log_bin配置

  如果想在主庫上執行一些操作,但不復制到slave庫上,可以通過修改參數sql_log_bin來實現。比如說,這里模擬主從同步復制異常。

   還有一種場景,就是導入或者刪除大批量數據時,分別在主庫和從庫上執行,而不需要通過復制方式來達到一致。

  

-- 在從庫上執行
mysql> set sql_log_bin=0;#設為0后,在Master數據庫上執行的語句都不記錄binlog
mysql> delete from t1 where id = 3; # 例如,該刪除操作,將不會記錄binlog中
mysql> set sql_log_bin=1;
-- 要慎重使用global修飾符(set global sql_log_bin=0),這樣會導致所有在Master數據庫上執行的語句都不記錄到binlog,這肯定不是你想要的結果
-- 在主庫上執行
mysql> delete from t1 where id = 3;
-- 在從庫上執行
mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.192.30.53
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 703173
               Relay_Log_File: fudao_db_cluster_003-relay-bin.000002
                Relay_Log_Pos: 2656
        Relay_Master_Log_File: mysql-bin.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: No
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: test.%,information_schema.%
                   Last_Errno: 1032
                   Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction '46760eb0-bcb3-11e9-a352-24a9c4e7e87e:73' at master log mysql-bin.000002, end_log_pos 703142. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 702860
              Relay_Log_Space: 3192
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 1032
               Last_SQL_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction '46760eb0-bcb3-11e9-a352-24a9c4e7e87e:73' at master log mysql-bin.000002, end_log_pos 703142. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 3306
                  Master_UUID: 46760eb0-bcb3-11e9-a352-24a9c4e7e87e
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: 
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 190813 11:22:24
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 46760eb0-bcb3-11e9-a352-24a9c4e7e87e:66-73
            Executed_Gtid_Set: 46760eb0-bcb3-11e9-a352-24a9c4e7e87e:1-72
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 0
            Network_Namespace: 
1 row in set (0.00 sec)

ERROR: 
No query specified

mysql> 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM