經過查看從服務器的狀態,能夠看到對應的錯誤信息mysql
mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.77.134 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: syntest.000001 Read_Master_Log_Pos: 13691 Relay_Log_File: centos0-relay-bin.000002 Relay_Log_Pos: 318 Relay_Master_Log_File: syntest.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: 1062 Last_Error: Error 'Duplicate entry 'xxx' for key 'PRIMARY'' on query. Default database:... ...
一、 再次同步一次sql
mysql> stop slave; Query OK, 0 rows affected, 1 warning (0.03 sec) mysql> change master to master_host='192.168.77.134', master_user='repl', master_password='test111', master_log_file='syntest.000001', master_log_pos=13691; Query OK, 0 rows affected, 2 warnings (0.20 sec) mysql> start slave; Query OK, 0 rows affected (0.24 sec)
二、跳過當前這個錯誤,在從庫中執行centos
mysql> stop slave; Query OK, 0 rows affected, 1 warning (0.03 sec) mysql> set global sql_slave_skip_counter=1; -- 1 指跳過一個錯誤 Query OK, 0 rows affected (0.00 sec) mysql> start slave; Query OK, 0 rows affected (0.24 sec)
三、忽略該類型的錯誤,更改從庫的配置,[mysqld]下加一行slave_skip_errors = 1062 ,保存重啓mysql(/etc/init.d/mysqld restart)。服務器