Mysql replication master switching from traditional model GTID mode ----

Traditional model (binlog + position) is switched to the copy replication GTID:

1) from the main library and the library modify parameters enforce_gtid_consistency = warn, then observed error log, confirmed that no incompatible GTID statement.

mysql> set @@global.enforce_gtid_consistency=warn;
Query OK, 0 rows affected (0.12 sec)

enforce_gtid_consistency:
    Scope:Global
    Dynamic:Yes(>= 5.7.6) No(<= 5.7.5)
    Type:Enumeration(>= 5.7.6) Boolean(<= 5.7.5)
    Default Value:OFF(>= 5.7.6) false(<= 5.7.5)
    Valid Values OFF\ON\WARN

Depending on the value of this variable, the server enforces GTID consistency by allowing execution of only statements that can be safely logged using a GTID. You must set this variable to ON before enabling GTID based replication.
    
The values that enforce_gtid_consistency can be configured to are:
    OFF: all transactions are allowed to violate GTID consistency.
    ON: no transaction is allowed to violate GTID consistency.
    WARN: all transactions are allowed to violate GTID consistency, but a warning is generated in this case. WARN was added in MySQL 5.7.6.

Do not support the following syntax GTID:
    1.Create TABLE ... the SELECT ..
        This statement will be split into two create table and insert table transactions and assign the same GTID, later spread to the standby database, insert will be ignored
        ERROR 1786 (HY000): Consistency of Statement violates GTID: the CREATE TABLE ... the SELECT.
    2. the CREATE TEMPORARY TABLE in the internal affairs of TEMPORARY TABLE DROP and
        ERROR 1787 (HY000): Consistency of Statement violates GTID: the CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE CAN only Outside of the transactional context the Executed BE.
        THESE Also statements are not allowed in a function or the Trigger Because the Triggers are Functions and Also Considered to BE Multi-of Statement transactions.
    3. while updating a non-transactional engine tables and tables in a transaction engine internal affairs
        ERROR 1785 (HY000): When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions,and never in the same statement as updates to transactional tables.

2) modifying the parameters from the main library and the library enforce_gtid_consistency = on (remember to modify my.cnf configuration file)

mysql> set @@global.enforce_gtid_consistency=on;
Query OK, 0 rows affected (0.00 sec)


3) a main bank and simultaneously modify parameters gtid_mode from the library, the order of OFF -> OFF_PERMISSIVE -> ON_PERMISSIVE -> ON (remember modify my.cnf configuration file)

mysql> set @@global.gtid_mode = on_permissive;
ERROR 1788 (HY000): The value of @@GLOBAL.GTID_MODE can only be changed one step at a time: OFF <-> OFF_PERMISSIVE <-> ON_PERMISSIVE <-> ON. Also note that this value must be stepped up or down simultaneously on all servers. See the Manual for instructions.
mysql> set @@global.gtid_mode = off_permissive;
Query OK, 0 rows affected (0.30 sec)

mysql> set @@global.gtid_mode = on_permissive;
Query OK, 0 rows affected (0.01 sec)

mysql> set @@global.gtid_mode = on;
Query OK, 0 rows affected (0.14 sec)

4) View from the library delay, no waiting for a transaction confirmation

mysql> show global status like '%ongoing_anonymous%';
+-------------------------------------+-------+
| Variable_name                       | Value |
+-------------------------------------+-------+
| Ongoing_anonymous_transaction_count | 0     |
+-------------------------------------+-------+
1 row in set (0.11 sec)

5) modified from the library copy mode
    1.stop Slave;
    2.CHANGE to master_auto_position = Master. 1;
    3.Start Slave;

6) the master-slave synchronization verification, in particular to observe the changes in the master library from the library and Executed_Gtid_Set Retrieved_Gtid_Set values ​​and Executed_Gtid_Set

mysql> show master status;
+------------------+----------+---------------------------------+------------------+------------------------------------------+
| File             | Position | Binlog_Do_DB                    | Binlog_Ignore_DB | Executed_Gtid_Set                        |
+------------------+----------+---------------------------------+------------------+------------------------------------------+
| mysql-bin.000037 |      949 | test,testrecovery,testrecovery2 |                  | 7842c967-0958-11e9-9f6c-000c296ee978:1-3 |
+------------------+----------+---------------------------------+------------------+------------------------------------------+
1 row in set (0.30 sec)
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.169.10.241
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000037
          Read_Master_Log_Pos: 949
               Relay_Log_File: LAPTOP-UC5V1DNQ-relay-bin.000002
                Relay_Log_Pos: 1162
        Relay_Master_Log_File: mysql-bin.000037
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: test,testrecovery,testrecovery2
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 949
              Relay_Log_Space: 1379
              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: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 10241
                  Master_UUID: 7842c967-0958-11e9-9f6c-000c296ee978
             Master_Info_File: E:\mysql-5.7.24-winx64\data\master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 7842c967-0958-11e9-9f6c-000c296ee978:1-3
            Executed_Gtid_Set: 7842c967-0958-11e9-9f6c-000c296ee978:1-3
                Auto_Position: 1
         Replicate_Rewrite_DB:
                 Channel_Name:
           Master_TLS_Version:
1 row in set (0.00 sec)

 

Guess you like

Origin blog.csdn.net/u014710633/article/details/93774379