MySQL GTID replication error handling skipping error, mysqlgtid

Source: Internet
Author: User

MySQL GTID replication error handling skipping error, mysqlgtid

An Slave error message:

mysql> show slave status\G;
mysql> show slave status\G;*************************** 1. row ***************************               Slave_IO_State: Waiting for master to send event                  Master_Host: 192.168.206.140                  Master_User: u_repl                  Master_Port: 3306                Connect_Retry: 60              Master_Log_File: mysql-bin.000002          Read_Master_Log_Pos: 499               Relay_Log_File: localhost-relay-bin.000002                Relay_Log_Pos: 367        Relay_Master_Log_File: mysql-bin.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: 1007                   Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction '9e2c7c0f-0908-11e7-8230-000c29ab7544:1' at master log mysql-bin.000001, end_log_pos 313. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.                 Skip_Counter: 0          Exec_Master_Log_Pos: 154              Relay_Log_Space: 1513              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: NULLMaster_SSL_Verify_Server_Cert: No                Last_IO_Errno: 0                Last_IO_Error:                Last_SQL_Errno: 1007               Last_SQL_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction '9e2c7c0f-0908-11e7-8230-000c29ab7544:1' at master log mysql-bin.000001, end_log_pos 313. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.  Replicate_Ignore_Server_Ids:              Master_Server_Id: 140                  Master_UUID: 9e2c7c0f-0908-11e7-8230-000c29ab7544             Master_Info_File: mysql.slave_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: 170316 04:25:29               Master_SSL_Crl:            Master_SSL_Crlpath:            Retrieved_Gtid_Set: 9e2c7c0f-0908-11e7-8230-000c29ab7544:1-2            Executed_Gtid_Set: 347cbac6-0906-11e7-b957-000c2981a46e:1,c59a2526-08fd-11e7-a5c7-000c296f2953:1-2                Auto_Position: 1         Replicate_Rewrite_DB:                  Channel_Name:            Master_TLS_Version: 1 row in set (0.00 sec)ERROR: No query specified
View Code

GTID replication is not very readable for error messages, but it can be performed from the monitoring table through error code (1007 ).Replication_applier_status_by_workerView:

mysql> select * from performance_schema.replication_applier_status_by_worker where LAST_ERROR_NUMBER=1007\G
mysql> select * from performance_schema.replication_applier_status_by_worker where LAST_ERROR_NUMBER=1007\G*************************** 1. row ***************************         CHANNEL_NAME:             WORKER_ID: 2            THREAD_ID: NULL        SERVICE_STATE: OFFLAST_SEEN_TRANSACTION: 9e2c7c0f-0908-11e7-8230-000c29ab7544:1    LAST_ERROR_NUMBER: 1007   LAST_ERROR_MESSAGE: Worker 1 failed executing transaction '9e2c7c0f-0908-11e7-8230-000c29ab7544:1' at master log mysql-bin.000001, end_log_pos 313; Error 'Can't create database 'mydb'; database exists' on query. Default database: 'mydb'. Query: 'create database mydb' LAST_ERROR_TIMESTAMP: 2017-03-16 04:25:291 row in set (0.00 sec)
View Code

How to skip an error using GTID: Locate the wrong GTID and skip (use Exec_Master_Log_Pos to find GTID in binlog, or use the above monitoring tableReplication_applier_status_by_workerFind GTID, you can also use Executed_Gtid_Set to calculate GTID), here we use the monitoring table to find the wrong GTID. After finding GTID,Skip the wrong step:

Mysql> stop slave; # stop synchronizing Query OK, 0 rows affected (0.02 sec) mysql> set @ session. gtid_next = '9e2c7c0f-keys: 1'; # Skip the wrong GTIDQuery OK, 0 rows affected (0.00 sec) mysql> begin; # submit an empty transaction because after gtid_next is set, the life cycle of gtid starts, and a transaction must be committed explicitly. Otherwise, an ERROR occurs: ERROR 1790 (HY000): @ SESSION. GTID_NEXT cannot be changed by a client that owns aQuery OK, 0 rows affected (0.00 sec) mysql> commit; Query OK, 0 rows affected (0.01 sec) mysql> set @ session. gtid_next = automatic; # set back to automatic mode Query OK, 0 rows affected (0.00 sec) mysql> start slave; Query OK, 0 rows affected (0.02 sec)

Confirm the slave synchronization status again

mysql> show slave status\G;
mysql> show slave status\G;*************************** 1. row ***************************               Slave_IO_State: Waiting for master to send event                  Master_Host: 192.168.206.140                  Master_User: u_repl                  Master_Port: 3306                Connect_Retry: 60              Master_Log_File: mysql-bin.000002          Read_Master_Log_Pos: 499               Relay_Log_File: localhost-relay-bin.000004                Relay_Log_Pos: 454        Relay_Master_Log_File: mysql-bin.000002             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: 499              Relay_Log_Space: 2024              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: 0Master_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: 140                  Master_UUID: 9e2c7c0f-0908-11e7-8230-000c29ab7544             Master_Info_File: mysql.slave_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: 9e2c7c0f-0908-11e7-8230-000c29ab7544:1-2            Executed_Gtid_Set: 347cbac6-0906-11e7-b957-000c2981a46e:1,9e2c7c0f-0908-11e7-8230-000c29ab7544:1-2,c59a2526-08fd-11e7-a5c7-000c296f2953:1-2                Auto_Position: 1         Replicate_Rewrite_DB:                  Channel_Name:            Master_TLS_Version: 1 row in set (0.00 sec)ERROR: No query specified
View Code

Close

Address: http://www.cnblogs.com/ajiangg/p/6558714.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.