zoukankan      html  css  js  c++  java
  • 从库找不到对应的被删除的记录

    1.实验演示环境
    --主库版本:
    root@(none)>show variables like 'version';
    +---------------+---------------------+
    | Variable_name | Value               |
    +---------------+---------------------+
    | version       | 5.7.23-23-31.31-log |
    +---------------+---------------------+
    1 row in set (0.01 sec)
    
    --复制模式
    root@(none)>show variables like '%gtid_mode%';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | gtid_mode     | ON    |
    +---------------+-------+
    1 row in set (0.00 sec)
    
    --复制进程
    root@(none)>show processlist;
    +----+-----------------+---------------------+-------+------------------+-------+---------------------------------------------------------------+------------------+-----------+---------------+
    | Id | User            | Host                | db    | Command          | Time  | State                                                         | Info             | Rows_sent | Rows_examined |
    +----+-----------------+---------------------+-------+------------------+-------+---------------------------------------------------------------+------------------+-----------+---------------+
    |  1 | event_scheduler | localhost           | NULL  | Daemon           | 14232 | Waiting on empty queue                                        | NULL             |         0 |             0 |
    |  9 | repl            | 192.168.2.101:53422 | NULL  | Binlog Dump GTID | 11941 | Master has sent all binlog to slave; waiting for more updates | NULL             |         0 |             0 |
    | 14 | root            | localhost           | NULL  | Query            |     0 | starting                                                      | show processlist |         0 |             0 |
    +----+-----------------+---------------------+-------+------------------+-------+---------------------------------------------------------------+------------------+-----------+---------------+
    8 rows in set (0.00 sec)
    
    root@(none)>
    
    --从库状态
    root@(none)>show slave status G;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.2.100
                      Master_User: repl
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000014
              Read_Master_Log_Pos: 194
                   Relay_Log_File: relay-bin.000005
                    Relay_Log_Pos: 407
            Relay_Master_Log_File: mysql-bin.000014
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                      Master_UUID: 015d4d11-0363-11e9-bb6c-0800279a3030
                 Master_Info_File: /mysql/3306/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
    
               Retrieved_Gtid_Set: 015d4d11-0363-11e9-bb6c-0800279a3030:1-4
                Executed_Gtid_Set: 015d4d11-0363-11e9-bb6c-0800279a3030:1-4
                    Auto_Position: 1
    1 row in set (0.00 sec)
    root@(none)>
    
    --主库记录:
    root@pxc01>select * from tbx;
    +------+
    | id   |
    +------+
    |    4 |
    |    5 |
    |    6 |
    +------+
    
    --从库记录:
    root@pxc01>select * from tbx;
    +------+
    | id   |
    +------+
    |    1 |
    |    2 |
    |    3 |
    |    4 |
    |    5 |
    |    6 |
    +------+
    6 rows in
    
    2.从库找不到对应的被删除的记录
    -- 如果是在主库上删除记录,而从库上找不到对应的记录,则可以直接跳过该事务
    -- 下面我们首选在从库上删除一条记录
    root@pxc01>delete from tbx where id=6;
    Query OK, 1 row affected (0.01 sec)
    
    -- 接下来在主库上删除该记录
    root@pxc01>delete from tbx where id=6;
    Query OK, 1 row affected (0.11 sec)
    
    root@pxc01>
    
    -- 从库端提示无法找到对应的记录
    root@pxc01>system clear
    root@pxc01>show slave status G;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.2.100
                      Master_User: repl
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000015
              Read_Master_Log_Pos: 1218
                   Relay_Log_File: relay-bin.000006
                    Relay_Log_Pos: 1175
            Relay_Master_Log_File: mysql-bin.000015
                 Slave_IO_Running: Yes
                Slave_SQL_Running: No
                       Last_Errno: 1032
                       Last_Error: Could not execute Delete_rows event on table pxc01.tbx; Can't find record in 'tbx', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log mysql-bin.000015, end_log_pos 1187
                     Skip_Counter: 0
              Exec_Master_Log_Pos: 962
                  Relay_Log_Space: 2397
                  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 pxc01.tbx; Can't find record in 'tbx', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log mysql-bin.000015, end_log_pos 1187
      Replicate_Ignore_Server_Ids: 
                 Master_Server_Id: 1
                      Master_UUID: 015d4d11-0363-11e9-bb6c-0800279a3030
                 Master_Info_File: /mysql/3306/data/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: 190106 23:02:52
                   Master_SSL_Crl: 
               Master_SSL_Crlpath: 
               Retrieved_Gtid_Set: 015d4d11-0363-11e9-bb6c-0800279a3030:1-6:8-11
                Executed_Gtid_Set: 015d4d11-0363-11e9-bb6c-0800279a3030:1-10,
    2b4452cb-119d-11e9-a121-0800279a3030:1
                    Auto_Position: 1
             Replicate_Rewrite_DB: 
                     Channel_Name: 
               Master_TLS_Version: 
    1 row in set (0.00 sec)
    
    --下面通过注入空事务来跳过
    root@pxc01>stop slave sql_thread;
    root@pxc01>set gtid_next='015d4d11-0363-11e9-bb6c-0800279a3030:11';
    root@pxc01>begin;commit;
    root@pxc01>set gtid_next='AUTOMATIC';
    root@pxc01>start slave sql_thread;
    root@pxc01>
    
    root@pxc01>show slave status G
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.2.100
                      Master_User: repl
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000015
              Read_Master_Log_Pos: 1218
                   Relay_Log_File: relay-bin.000006
                    Relay_Log_Pos: 1431
            Relay_Master_Log_File: mysql-bin.000015
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                  Replicate_Do_DB: 
              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: 1218
                  Relay_Log_Space: 2397
                  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: 1
                      Master_UUID: 015d4d11-0363-11e9-bb6c-0800279a3030
                 Master_Info_File: /mysql/3306/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: 015d4d11-0363-11e9-bb6c-0800279a3030:1-6:8-11
                Executed_Gtid_Set: 015d4d11-0363-11e9-bb6c-0800279a3030:1-11,
    2b4452cb-119d-11e9-a121-0800279a3030:1
                    Auto_Position: 1
             Replicate_Rewrite_DB: 
                     Channel_Name: 
               Master_TLS_Version: 
    1 row in set (0.00 sec)
    
    root@pxc01>
  • 相关阅读:
    线性回归问题
    聚类:层次聚类
    聚类:(K-means)算法
    神经网络算法
    AutoEventWireup解释
    asp.net中runat="server"的含义
    十步完全理解SQL
    sqlserver中分区函数 partition by的用法
    被忽略却很有用的html标签
    net中使用母版页
  • 原文地址:https://www.cnblogs.com/polestar/p/10796583.html
Copyright © 2011-2022 走看看