title | summary | category |
---|---|---|
Data Migration Task Configuration Options |
This document introduces the configuration options that apply to Data Migration tasks. |
tools |
This document introduces the configuration options that apply to Data Migration tasks.
-
String (
full
/incremental
/all
) -
The task mode of data migration to be executed
-
Default value:
all
full
: Only makes a full backup of the upstream database and then restores it to the downstream database.incremental
: Only synchronizes the incremental data of the upstream database to the downstream database using the binlog.all
:full
+incremental
. Makes a full backup of the upstream database, imports the full data to the downstream database, and then uses the binlog to make an incremental synchronization to the downstream database starting from the exported position during the full backup process (binlog position/GTID).
# `schema-pattern`/`table-pattern` uses the wildcard matching rule
schema level:
schema-pattern: "test_*"
target-schema: "test"
table level:
schema-pattern: "test_*"
table-pattern: "t_*"
target-schema: "test"
target-table: "t"
Description: Synchronizes the upstream table data that matches schema-pattern
/table-pattern
to the downstream target-schema
/target-table
. You can set the routing rule at the schema/table level.
Taking the above code block as an example:
-
Schema level: Synchronizes all the upstream tables that match the
test_*
schema to the downstreamtest
schema.For example,
schema: test_1 - tables [a, b, c]
=>schema:test - tables [a, b, c]
-
Table level: Synchronizes the
t_*
matched upstream tables withtest_*
matched schema to the downstreamschema:test table:t
table.
Notes:
- The
table level
rule has a higher priority than theschema level
rule.- You can set one routing rule at most at one level.
instance:
do-dbs: ["~^test.*", "do"] # Starts with "~", indicating it is a regular expression
ignore-dbs: ["mysql", "ignored"]
do-tables:
- db-name: "~^test.*"
tbl-name: "~^t.*"
- db-name: "do"
tbl-name: "do"
ignore-tables:
- db-name: "do"
tbl-name: "do"
The black and white lists filtering rule of the upstream database instances is similar to MySQL replication-rules-db
/replication-rules-table
.
The filter process is as follows:
-
Filter at the schema level:
-
If
do-dbs
is not empty, judge whether a matched schema exists indo-dbs
.- If yes, continue to filter at the table level.
- If not, ignore it and exit.
-
If
do-dbs
is empty, andignore-dbs
is not empty, judge whether a matched schema exits inignore-dbs
.- If yes, ignore it and exit.
- If not, continue to filter at the table level.
-
If both
do-dbs
andignore-dbs
are empty, continue to filter at the table level.
-
-
Filter at the table level:
-
If
do-tables
is not empty, judge whether a matched rule exists indo-tables
.- If yes, exit and execute the statement.
- If not, continue to the next step.
-
If
ignore tables
is not empty, judge whether a matched rule exists inignore-tables
.- If yes, ignore it and exit.
- If not, continue to the next step.
-
If
do-tables
is not empty, ignore it and exit. Otherwise, exit and execute the statement.
-
# table level
user-filter-1:
schema-pattern: "test_*" # `schema-pattern`/`table-pattern` uses the wildcard matching rule.
table-pattern: "t_*"
events: ["truncate table", "drop table"]
sql-pattern: ["^DROP\\s+PROCEDURE", "^CREATE\\s+PROCEDURE"]
action: Ignore
# schema level
user-filter-2:
schema-pattern: "test_*"
events: ["All DML"]
action: Do
Description: Configures the filtering rules for binlog events and DDL SQL statements of the upstream tables that match schema-pattern
/table-pattern
.
-
events
: the binlog event arrayEvents Type Description all
Includes all the events below all dml
Includes all DML events below all ddl
Includes all DDL events below none
Includes none of the events below none ddl
Includes none of the DDL events below none dml
Includes none of the DML events below insert
DML The INSERT
DML eventupdate
DML The UPDATE
DML eventdelete
DML The DELETE
DML eventcreate database
DDL The CREATE DATABASE
DDL eventdrop database
DDL The DROP DATABASE
DDL eventcreate table
DDL The CREATE TABLE
DDL eventcreate index
DDL The CREATE INDEX
DDL eventdrop table
DDL The DROP TABLE
DDL eventtruncate table
DDL The TRUNCATE TABLE
DDL eventrename table
DDL The RENAME TABLE
DDL eventdrop index
DDL The DROP INDEX
DDL eventalter table
DDL The ALTER TABLE
DDL event -
sql-pattern
- Filters a specific DDL SQL statement.
- The matching rule supports using an regular expression, for example,
"^DROP\\s+PROCEDURE"
.
Note: If
sql-pattern
is empty, no filtering operation is performed. For the filtering rules, see theaction
description.
-
action
-
String (
Do
/Ignore
) -
For rules that match
schema-pattern
/table-pattern
, judge whether the DDL statement is in the events of the rule orsql-pattern
.- Black list: If
action = Ignore
, executeIgnore
; otherwise executeDo
. - White list: If
action = Ignore
, executeDo
; otherwise executeIgnore
.
- Black list: If
-
instance-1:
schema-pattern: "test_*" # `schema-pattern`/`table-pattern` uses the wildcard matching rule
table-pattern: "t_*"
expression: "partition id"
source-column: "id"
target-column: "id"
arguments: ["1", "test_", "t_"]
instance-2:
schema-pattern: "test_*"
table-pattern: "t_*"
expression: "partition id"
source-column: "id"
target-column: "id"
arguments: ["2", "test_", "t_"]
Description: the rules for mapping the columns of schema-pattern
/table-pattern
matched tables in upstream database instances. It is used to resolve the conflicts of auto-increment primary keys of sharded tables.
-
source-column
,target-column
: Usesexpression
to compute the data ofsource-column
as the data oftarget-column
. -
expression
: The expression used to convert the column data. Currently, only the following built-in expression is supported:-
partition id
-
You need to set
arguments
to[instance_id, prefix of schema, prefix of table]
.- schema name = arguments[1] + schema ID(suffix of schema); schema ID == suffix of schema
- table name = argument[2] + table ID(suffix of table); table ID == suffix of table
- If argument[0] == "", the partition ID takes up 0 bit in the figure below; otherwise, it takes up 4 bits (by default)
- If argument[1] == "", the schema ID takes up 0 bit in the figure below; otherwise, it takes up 7 bits (by default)
- If argument[2] == "", the table ID takes up 0 bit in the figure below; otherwise, it takes up 8 bits (by default)
- The origin ID is the value of the auto-increment ID column of a row in the table
-
Restrictions:
- It is only applicable to the bigint column.
- The instance ID value should be (>= 0, <= 15) (4 bits by default)
- The schema ID value should be (>= 0, <= 127) (7 bits by default)
- The table ID value should be (>= 0, <= 255) (8 bits by default)
- The origin ID value should be (>= 0, <= 17592186044415) (44 bits by default)
-
-