Es kann vorkommen dass eine MySQL replication aufgrund eines Fehlers anhält. Diesen sehen wir denn wir uns den slave_status ansehen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
mysql -u root -p mysql> SHOW SLAVE STATUS \G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.0.1 Master_User: mysql_user Master_Port: 3306 Connect_Retry: 10 Master_Log_File: mysql-bin.000090 Read_Master_Log_Pos: 101338719 Relay_Log_File: mysqld-relay-bin.000196 Relay_Log_Pos: 280017 Relay_Master_Log_File: mysql-bin.000078 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: 1062 Last_Error: Could not execute Write_rows event on table myblog.counters; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000078, end_log_pos 280037 Skip_Counter: 0 Exec_Master_Log_Pos: 279871 Relay_Log_Space: 1362201315 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: 1062 Last_SQL_Error: Could not execute Write_rows event on table myblog.counters; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000078, end_log_pos 280037 Replicate_Ignore_Server_Ids: Master_Server_Id: 2 |
Diesen MySQL replication Fehler können wir beheben in dem wir die query überspringen. Das funktioniert folgendermaßen
1 2 3 4 5 |
mysql> STOP SLAVE; mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; mysql> START SLAVE; |
Wenn wir uns erneut den slave_status ansehen sollte wieder alles OK sein.