Considerations for MySQL replication Filtering

Source: Internet
Author: User
Considerations for MySQL replication Filtering: when there are DB filtering rules, the USE statement must be used in statment mode, and the form of db. Table Name, db. View, db. Storage program cannot appear.

Considerations for MySQL replication Filtering: when there are DB filtering rules, the USE statement must be used in statment mode, and the form of db. Table Name, db. View, db. Storage program cannot appear.

1. replicate_do_db and replicate_ignore_db do not appear at the same time. It is prone to confusion. It is meaningless.
Replicate_Do_DB: db1
Replicate_Ignore_DB: db2

Statement mode:
Use the use statement
Use db1; insert into tb1 values (1 );
Use db2; insert into tb2 values (2 );
The above data can be correctly copied on slave, tb1 has data, and tb2 has no data.

Do not use the use statement
Insert into db1.tb1 values (11 );
Insert into db2.tb2 values (11 );
As a result, tb1 has no data and tb2 has no data (as mentioned in the document, there should be data)

Row mode:
Whether or not the use statement is used, it can be copied correctly.
Summary: For the statement mode, the SQL statement must use the use statement and set multiple replicate_do_db to copy multiple databases.

2. When table-level filtering is performed only, statement mode can be correctly copied regardless of whether the use statement is used. The row mode is also supported. (The full name of the table that matches the table name: database name + Table name)
Replicate_do_table = db1.tb1
Statement mode:
Use db1; insert into tb1 values (22 );
Insert into db1.tb1 values (22 );
The replication results are consistent.
(Do and ignore should not be mixed unless DB filtering occurs)

3. When DB filtering rules are available, the USE statement must be used in statment mode. The format db. Table Name, db. view, and db. Storage program cannot appear. Row mode wins!
Replicate-ignore-db = db1
Replicate-do-table = db2.tbl2

USE db1;
Insert into db2.tbl2 VALUES (1 );

In row mode,
The default DB is not db1, so the first rule is skipped, the table rule is executed, and the row is inserted.

In statement mode,
The insert statement is ignored, and the table filtering rules are stopped at the DB level, so no check is performed.

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.