Replication in Gtid mode, how to skip error log resolution

Source: Internet
Author: User


Log error:

Most replication errors are caused by log errors.

Both the primary log and the relay log can be faulted.

Methods for judging Log errors:

Mysqlbinlog master_binlog_file >/dev/null The output of the screen indicates that this binlog has errors, if not, it means binlog normal,

Mysqlbinlog Slave_binlog_file >/dev/null



Skip Log Error 1:

You can use manual skip log errors, which can result in inconsistent data

If there is an error in the primary log, it can be executed again on slave (multiple actions may be required if there is more than one error)

Mysql>stop slave;

Mysql>set Global sql_slave_skip_counter=1;

Mysql>start slave;


This method does not apply to the Replication,gtids mode of the Dtid mode and does not allow Sql_slave_skip_counter


Skip error log 2: Gtid not supported

If there is an error in the cited log, you can review the replication status on slave and skip the error log based on the log information:


Mysql>stop slave;

Mysql>change Master to

master_log_file= ' Relay_master_log_file ';

master_log_pos=<exec_master_log_pos>;

Mysql>start slave;


The benefit of skipping the error log 3:gdit is that the computer handles itself without the hassle of being as old as before.

If the Binlog on master except the problem, cause slave cannot continue,

If replication is working in Gtid mode, the following actions are required:

Mysql>stop slave;

Mysql>set gtid_next= ' uuid.next_id ';

mysql>begin;

mysql>commit;

Mysql>set gtid_next= ' autocommit ';

Mysql>start slave;

Uuid:nextid Example: 8a1f84c4-9d67-11e4-8a9a-3085a9eb338b:12


Into


Analog failure: Based on Dtid mode

In master:

Mysql>use viewdb

Mysql> select * from T1;

+------+

| ID |

+------+

| 112 |

| 113 |

| 114 |

| 115 |

| 116 |

| 117 |

| 118 |

| 119 |

| 120 |

| 1000 |

| 110 |

| 109 |

Mysql>show vaiiables like "%bin%" to find Sql_bin_log

Sql_log_bin | On global parameters, the current operation is logged to the binary days,


Mysql> set Sql_log_bin=off; Indicates that the current operation is not logged in the binary log. The next operation will not be synchronized to the slave, so the error

mysql> INSERT into T1 values (200);

Query OK, 1 row Affected (0.00 sec)


Mysql> select * from T1;

+------+

| ID |

+------+

| |

| 200 |

+------+

Rows in Set (0.00 sec

Mysql> set Sql_log_bin=on; Open Again,

Query OK, 0 rows Affected (0.00 sec)


mysql> INSERT INTO T1 values (201); This is 201 will be synced to salve,200 and will not sync to slave

Query OK, 1 row affected (0.03 sec)

In master


Mysql> select * from T1;

+------+

| ID |

+------+

| |

200

| 201 |


In SLAVE


Mysql> select * from T1;

+------+

| ID |

+------+

| |

| 201 |


Cut back to Master

Mysql>delect from T1 where id=200; After this step is finished, this action is logged to Binlog and will be synchronized to slave, at which point slave error is reported and the master's


A binlog end_log_pos error.

in slave;

Mysql>show Salve status\g;

Last_sql_error:could not execute Delete_rows event on table viewdb.t1; Can ' t find record in ' T1 ', error_code:1032;


Handler error ha_err_end_of_file; The event ' s master Log localhost-bin.000006, End_log_pos 1360

And:

Retrieved_gtid_set:61816754-9d68-11e4-8a9f-000c29c1d1ea:1-18

Executed_gtid_set:61816754-9d68-11e4-8a9f-000c29c1d1ea:1-17

Inconsistent


Cut back to Master

Mysql>insert into T1 valuses (202);

In slave

At this time due to slave failure, so slave will no longer have any new data synchronization.

Retrieved_gtid_set:61816754-9d68-11e4-8a9f-000c29c1d1ea:1-19

Executed_gtid_set:61816754-9d68-11e4-8a9f-000c29c1d1ea:1-17

This is where we skip this error,


mysql> stop Slave;

Query OK, 0 rows affected (0.01 sec)


Mysql> set gtid_next= ' 61816754-9d68-11e4-8a9f-000c29c1d1ea:18 ';

Mysql> begin;

Mysql> commit;

Mysql> set gtid_next= ' automatic ';

mysql> start slave;

Mysql>show slave status\g;

Mysql>select * from T1; The discovery data has been aligned.

The advantage of Gtid is that if there are two slave, only one slave is repaired. The other one is automatically updated to the normal state.


This article is from the "Crazy_sir" blog, make sure to keep this source http://douya.blog.51cto.com/6173221/1606480

Replication in Gtid mode, how to skip error log resolution

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.