What about mysql replication filter duplication

  • 2020-05-14 05:05:32
  • OfStack

1, replicate_do_db and replicate_ignore_db do not appear together. It's easy to get confused. It's 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);
All the above can be copied correctly on slave, tb1 has data, tb2 has no data.
use statements are not used
insert into db1.tb1 values (11);
insert into db2.tb2 values (11);
As a result, tb1 has no data, and tb2 has no data (which, according to the documentation, should have)
row mode:
Copy correctly whether or not an use statement is used
Summary: for statement mode, SQL statements must use use statements and set multiple replicate_do_db to copy multiple DB.
2. For table level filtering only, the statement schema can be copied correctly whether or not use statements are used. row mode is also acceptable. (table name the full name of the table it matches: database name + table name)
replicate_do_table=db1.tb1
statement mode:
use db1; insert into tb1 values (22);
insert into db1.tb1 values (22);
Both copies result 1 to 1.
(again, do not mix do and ignore, unless filtering DB occurs)
3. When there are DB filtering rules, statment mode must use USE statement, and db. table name, db. view, db. stored program, etc. row mode wins!
replicate-ignore-db = db1
replicate-do-table = db2.tbl2
USE db1;
INSERT INTO db2.tbl2 VALUES (1);
In row mode,
By default DB is not db1, so rule 1 is skipped, the rules of the table are executed, and the rows are inserted
In statement mode,
The insert statement was ignored, and the filtering rules for the table had stopped at the DB level, so no checks were made.

Related articles: