mysql主从不同步、数据不一致解决办法

提示报错:

Could not execute Write_rows event on table injured_dataplatform.injurysite; Duplicate entry '6864' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000412, end_log_pos 928740435

解决方法:

从库执行
#停止slave服务
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
#跳过一步错误,后面的数字可变,如果还不行可执行多次
mysql> set global sql_slave_skip_counter =1;
Query OK, 0 rows affected (0.00 sec)
#开始slave服务
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
#查看slave状态
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.20.195
                  Master_User: test
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000004
          Read_Master_Log_Pos: 251
               Relay_Log_File: mysqld-relay-bin.000006
                Relay_Log_Pos: 251
        Relay_Master_Log_File: mysql-bin.000004
             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: mysql.%,information_schema.%,performance_schema.%
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 1
          Exec_Master_Log_Pos: 251
              Relay_Log_Space: 552
              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:
1 row in set (0.00 sec)
 

猜你喜欢

转载自blog.csdn.net/guoshaoliang789/article/details/82496289