简体   繁体   中英

mysql replication failure with GTID and unable to recover it

I have configured MySQL replication and it was working fine. Accidentally I have deleted/modified some users on the slave and performed the same action on Master as well. After that the replication stopped and giving below error on `show slave status \\G'

mysql> show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: mysql-servers01
                  Master_User: mysqlreplica
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 1346
               Relay_Log_File: mysql-servers02-relay-bin.000002
                Relay_Log_Pos: 4681
        Relay_Master_Log_File: mysql-bin.000001
             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:
                   Last_Errno: 1032
                   Last_Error: Could not execute Delete_rows event on table mysql.user; Can't find record in 'user', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000001, end_log_pos 4974
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 4468
              Relay_Log_Space: 9096
              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: Could not execute Delete_rows event on table mysql.user; Can't find record in 'user', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000001, end_log_pos 4974
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
                  Master_UUID: aaa2545a-4437-11e7-9f03-0021f6f0406f
             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: 170529 21:06:36
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: aaa2545a-4437-11e7-9f03-0021f6f0406f:1-31
            Executed_Gtid_Set: aaa2545a-4437-11e7-9f03-0021f6f0406f:1-20:31,
acc29e29-4437-11e7-8074-0021f6f0406e:1-23
                Auto_Position: 0
         Replicate_Rewrite_DB:
                 Channel_Name:
           Master_TLS_Version:
1 row in set (0.00 sec)

mysql>

I have tried set SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1 which give below message,

mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with @@GLOBAL.GTID_MODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction

And I have also attempted below action which also didn't help,

mysql> STOP SLAVE;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GTID_NEXT="aaa2545a-4437-11e7-9f03-0021f6f0406f:20"
    -> ;
Query OK, 0 rows affected (0.00 sec)

mysql> BEGIN; COMMIT;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> SET GTID_NEXT="acc29e29-4437-11e7-8074-0021f6f0406e:23";
Query OK, 0 rows affected (0.01 sec)

mysql> BEGIN; COMMIT;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> SET GTID_NEXT="aaa2545a-4437-11e7-9f03-0021f6f0406f:31";
Query OK, 0 rows affected (0.00 sec)

mysql> BEGIN; COMMIT;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> SET GTID_NEXT="AUTOMATIC";
Query OK, 0 rows affected (0.01 sec)

mysql> START SLAVE;
Query OK, 0 rows affected (0.00 sec)

Is there any way to recover this and make the replication happen properly.

我已经在从节点上重新安装了MySQL并再次对其进行了配置。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM