mysql主從同步異常

查看主從狀態

主服務器

mysql> show master status;

+------------------+-----------+--------------+------------------+-------------------+

| File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+------------------+-----------+--------------+------------------+-------------------+

| mysql-bin.000467 | 509113942 |              |                  |                   |

+------------------+-----------+--------------+------------------+-------------------+

從服務器

mysql> show slave status\G

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 192.168.11.11

                  Master_User: repluser

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: mysql-bin.000467

          Read_Master_Log_Pos: 537072113

               Relay_Log_File: mysql-relay-bin.001357

                Relay_Log_Pos: 789610157

        Relay_Master_Log_File: mysql-bin.000454

             Slave_IO_Running: Yes

            Slave_SQL_Running: No

              Replicate_Do_DB: 

          Replicate_Ignore_DB: mysql,information_schema

           Replicate_Do_Table: 

       Replicate_Ignore_Table: 

      Replicate_Wild_Do_Table: 

  Replicate_Wild_Ignore_Table: 

                   Last_Errno: 1060

                   Last_Error: Error 'Duplicate column name 'AES_TEL1'' on query. ....

  

  

原因:

錯誤的認爲從庫是主庫,在從庫做了alter table 修改表結構,之後發現是從庫後又在主庫上做了該操作,主庫做完操作後從庫也會執行這個語句,但是由於從庫上已經做了修改,所以主從線程更改表失敗,就會看到從庫狀態如上面所示,手動解決這個問題:

mysql>set global sql_slave_skip_counter=1;

mysql>start slave;

告訴從庫,讓它忽略掉這個錯誤繼續執行同步。

參考:https://www.cnblogs.com/cobbliu/p/4227183.html


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章