データ移行タスクConfiguration / コンフィグレーションガイド

このドキュメントでは、データ移行(DM)でデータ移行タスクを構成する方法を紹介します。

移行するデータソースを構成する

タスク用に移行するデータソースを構成する前に、まずDMが対応するデータソースの構成ファイルをロードしていることを確認する必要があります。以下は、いくつかの操作リファレンスです。

次のmysql-instancesの例は、データ移行タスクのために移行する必要があるデータソースを構成する方法を示しています。

--- ## ********* Basic configuration ********* name: test # The name of the task. Should be globally unique. ## ******** Data source configuration ********** mysql-instances: - source-id: "mysql-replica-01" # Migrate data from the data source whose `source-id` is `mysql-replica-01`. - source-id: "mysql-replica-02" # Migrate data from the data source whose `source-id` is `mysql-replica-02`.

ダウンストリームTiDBクラスタを構成します

次のtarget-databaseの例は、データ移行タスクのために移行先のターゲットTiDBクラスタを構成する方法を示しています。

--- ## ********* Basic configuration ********* name: test # The name of the task. Should be globally unique. ## ******** Data source configuration ********** mysql-instances: - source-id: "mysql-replica-01" # Migrate data from the data source whose `source-id` is `mysql-replica-01`. - source-id: "mysql-replica-02" # Migrate data from the data source whose `source-id` is `mysql-replica-02`. ## ******** Downstream TiDB database configuration ********** target-database: # Configuration of target TiDB database. host: "127.0.0.1" port: 4000 user: "root" password: "" # If the password is not null, it is recommended to use a password encrypted with dmctl.

移行するテーブルを構成する

ノート:

特定のテーブルをフィルタリングしたり、特定のテーブルを移行したりする必要がない場合は、この構成をスキップしてください。

ブロックを構成し、データ移行タスクのデータソーステーブルのリストを許可するには、次の手順を実行します。

  1. ブロックのグローバルフィルタールールセットを構成し、タスク構成ファイルのリストを許可します。

    block-allow-list: bw-rule-1: # The name of the block and allow list rule. do-dbs: ["test.*", "user"] # The allow list of upstream schemas to be migrated. Wildcard characters (*?) are supported. You only need to configure either `do-dbs` or `ignore-dbs`. If both fields are configured, only `do-dbs` takes effect. # ignore-dbs: ["mysql", "account"] # The block list of upstream schemas to be migrated. Wildcard characters (*?) are supported. do-tables: # The allow list of upstream tables to be migrated. You only need to configure either `do-tables` or `ignore-tables`. If both fields are configured, only `do-tables` takes effect. - db-name: "test.*" tbl-name: "t.*" - db-name: "user" tbl-name: "information" bw-rule-2: # The name of the block allow list rule. ignore-tables: # The block list of data source tables needs to be migrated. - db-name: "user" tbl-name: "log"

    詳細な構成ルールについては、 テーブルリストをブロックして許可するを参照してください。

  2. ブロックを参照し、データソース構成のリストルールを許可して、移行するテーブルをフィルタリングします。

    mysql-instances: - source-id: "mysql-replica-01" # Migrate data from the data source whose `source-id` is `mysql-replica-01`. block-allow-list: "bw-rule-1" # The name of the block and allow list rule. If the DM version is earlier than v2.0.0-beta.2, use `black-white-list` instead. - source-id: "mysql-replica-02" # Migrate data from the data source whose `source-id` is `mysql-replica-02`. block-allow-list: "bw-rule-2" # The name of the block and allow list rule. If the DM version is earlier than v2.0.0-beta.2, use `black-white-list` instead.

移行するbinlogイベントを構成します

ノート:

特定のスキーマまたはテーブルの特定のbinlogイベントをフィルタリングする必要がない場合は、この構成をスキップしてください。

データ移行タスクのbinlogイベントのフィルターを構成するには、次の手順を実行します。

  1. タスク構成ファイルでbinlogイベントのグローバルフィルタールールセットを構成します。

    filters: # The filter rule set of data source binlog events. You can set multiple rules at the same time. filter-rule-1: # The name of the filtering rule. schema-pattern: "test_*" # The pattern of the data source schema name. Wildcard characters (*?) are supported. table-pattern: "t_*" # The pattern of the data source table name. Wildcard characters (*?) are supported. events: ["truncate table", "drop table"] # The event types to be filtered out in schemas or tables that match the `schema-pattern` or the `table-pattern`. action: Ignore # Whether to migrate (Do) or ignore (Ignore) the binlog that matches the filtering rule. filter-rule-2: schema-pattern: "test" events: ["all dml"] action: Do

    詳細な構成ルールについては、 Binlogイベントフィルターを参照してください。

  2. データソース構成のbinlogイベントフィルタリングルールを参照して、データソース内の指定されたテーブルまたはスキーマの指定されたbinlogイベントをフィルタリングします。

    mysql-instances: - source-id: "mysql-replica-01" # Migrate data from the data source whose `source-id` is `mysql-replica-01`. block-allow-list: "bw-rule-1" # The name of the block and allow list rule. If the DM version is earlier than v2.0.0-beta.2, use `black-white-list` instead. filter-rules: ["filter-rule-1"] # The name of the rule that filters specific binlog events of the data source. You can configure multiple rules here. - source-id: "mysql-replica-02" # Migrate data from the data source whose `source-id` is `mysql-replica-01`. block-allow-list: "bw-rule-2" # The name of the block and allow list rule. If the DM version is earlier than v2.0.0-beta.2, use `black-white-list` instead. filter-rules: ["filter-rule-2"] # The name of the rule that filters specific binlog events of the data source. You can configure multiple rules here.

データソーステーブルからダウンストリームTiDBテーブルへのマッピングを構成します

ノート:

  • データソースの特定のテーブルをダウンストリームTiDBインスタンスの別の名前のテーブルに移行する必要がない場合は、この構成をスキップしてください。

  • シャードマージタスクの場合は、タスク構成ファイルでマッピングルールを設定する必要があります。

データソーステーブルを指定されたダウンストリームTiDBテーブルに移行するためのルーティングマッピングルールを設定するには、次の手順を実行します。

  1. タスク構成ファイルでグローバルルーティングマッピングルールセットを構成します。

    routes: # The routing mapping rule set between the data source tables and downstream TiDB tables. You can set multiple rules at the same time. route-rule-1: # The name of the routing mapping rule. schema-pattern: "test_*" # The pattern of the upstream schema name. Wildcard characters (*?) are supported. table-pattern: "t_*" # The pattern of the upstream table name. Wildcard characters (*?) are supported. target-schema: "test" # The name of the downstream TiDB schema. target-table: "t" # The name of the downstream TiDB table. route-rule-2: schema-pattern: "test_*" target-schema: "test"

    詳細な構成ルールについては、 テーブルルーティングを参照してください。

  2. 移行するテーブルをフィルタリングするには、データソース構成のルーティングマッピングルールを参照してください。

    mysql-instances: - source-id: "mysql-replica-01" # Migrate data from the data source whose `source-id` is `mysql-replica-01`. block-allow-list: "bw-rule-1" # The name of the block and allow list rule. If the DM version is earlier than v2.0.0-beta.2, use `black-white-list` instead. filter-rules: ["filter-rule-1"] # The name of the rule that filters specific binlog events of the data source. You can configure multiple rules here. route-rules: ["route-rule-1", "route-rule-2"] # The name of the routing mapping rule. You can configure multiple rules here. - source-id: "mysql-replica-02" # Migrate data from the data source whose `source-id` is `mysql-replica-02`. block-allow-list: "bw-rule-2" # The name of the block and allow list rule. If the DM version is earlier than v2.0.0-beta.2, use `black-white-list` instead. filter-rules: ["filter-rule-2"] # The name of the rule that filters specific binlog events of the data source. You can configure multiple rules here.

シャードマージタスクを構成する

ノート:

  • シャードマージシナリオでシャーディングDDLステートメントを移行する必要がある場合は、 shard-modeフィールドを明示的に構成する必要があります。それ以外の場合は、 shard-modeをまったく構成しないでください。

  • シャーディングDDLステートメントを移行すると、多くの問題が発生する可能性があります。この機能を使用する前に、DM移行DDLステートメントの原則と制限を理解していることを確認してください。この機能は注意して使用する必要があります。

次の例は、タスクをシャードマージタスクとして構成する方法を示しています。

--- ## ********* Basic information ********* name: test # The name of the task. Should be globally unique. shard-mode: "pessimistic" # The shard merge mode. Optional modes are ""/"pessimistic"/"optimistic". The "" mode is used by default which means sharding DDL merge is disabled. If the task is a shard merge task, set it to the "pessimistic" mode. After getting a deep understanding of the principles and restrictions of the "optimistic" mode, you can set it to the "optimistic" mode.

その他の構成

以下は、このドキュメントの全体的なタスク構成の例です。完全なタスク構成テンプレートはDMタスク構成ファイルの完全な紹介にあります。他の構成項目の使用法と構成については、 データ移行の機能を参照してください。

--- ## ********* Basic configuration ********* name: test # The name of the task. Should be globally unique. shard-mode: "pessimistic" # The shard merge mode. Optional modes are ""/"pessimistic"/"optimistic". The "" mode is used by default which means sharding DDL merge is disabled. If the task is a shard merge task, set it to the "pessimistic" mode. After getting a deep understanding of the principles and restrictions of the "optimistic" mode, you can set it to the "optimistic" mode. task-mode: all # The task mode. Can be set to `full`(only migrates full data)/`incremental`(replicates binlog synchronously)/`all` (replicates both full and incremental binlogs). timezone: "UTC" # The timezone used in SQL Session. By default, DM uses the global timezone setting in the target cluster, which ensures the correctness automatically. A customized timezone does not affect data migration but is unnecessary. ## ******** Data source configuration ********** mysql-instances: - source-id: "mysql-replica-01" # Migrate data from the data source whose `source-id` is `mysql-replica-01`. block-allow-list: "bw-rule-1" # The name of the block and allow list rule. If the DM version is earlier than v2.0.0-beta.2, use `black-white-list` instead. filter-rules: ["filter-rule-1"] # The name of the rule that filters specific binlog events of the data source. You can configure multiple rules here. route-rules: ["route-rule-1", "route-rule-2"] # The name of the routing mapping rule. You can configure multiple rules here. - source-id: "mysql-replica-02" # Migrate data from the data source whose `source-id` is `mysql-replica-02`. block-allow-list: "bw-rule-2" # The name of the block and allow list rule. If the DM version is earlier than v2.0.0-beta.2, use `black-white-list` instead. filter-rules: ["filter-rule-2"] # The name of the rule that filters specific binlog events of the data source. You can configure multiple rules here. route-rules: ["route-rule-2"] # The name of the routing mapping rule. You can configure multiple rules here. ## ******** Downstream TiDB instance configuration ********** target-database: # Configuration of the downstream database instance. host: "127.0.0.1" port: 4000 user: "root" password: "" # If the password is not null, it is recommended to use a password encrypted with dmctl. ## ******** Feature configuration set ********** # The filter rule set of tables to be migrated from the upstream database instance. You can set multiple rules at the same time. block-allow-list: # Use black-white-list if the DM version is earlier than v2.0.0-beta.2. bw-rule-1: # The name of the block and allow list rule. do-dbs: ["test.*", "user"] # The allow list of upstream schemas to be migrated. Wildcard characters (*?) are supported. You only need to configure either `do-dbs` or `ignore-dbs`. If both fields are configured, only `do-dbs` takes effect. # ignore-dbs: ["mysql", "account"] # The block list of upstream schemas to be migrated. Wildcard characters (*?) are supported. do-tables: # The allow list of upstream tables to be migrated. You only need to configure either `do-tables` or `ignore-tables`. If both fields are configured, only `do-tables` takes effect. - db-name: "test.*" tbl-name: "t.*" - db-name: "user" tbl-name: "information" bw-rule-2: # The name of the block allow list rule. ignore-tables: # The block list of data source tables needs to be migrated. - db-name: "user" tbl-name: "log" # The filter rule set of data source binlog events. filters: # You can set multiple rules at the same time. filter-rule-1: # The name of the filtering rule. schema-pattern: "test_*" # The pattern of the data source schema name. Wildcard characters (*?) are supported. table-pattern: "t_*" # The pattern of the data source table name. Wildcard characters (*?) are supported. events: ["truncate table", "drop table"] # The event types to be filtered out in schemas or tables that match the `schema-pattern` or the `table-pattern`. action: Ignore # Whether to migrate (Do) or ignore (Ignore) the binlog that matches the filtering rule. filter-rule-2: schema-pattern: "test" events: ["all dml"] action: Do # The routing mapping rule set between the data source and target TiDB instance tables. routes: # You can set multiple rules at the same time. route-rule-1: # The name of the routing mapping rule. schema-pattern: "test_*" # The pattern of the data source schema name. Wildcard characters (*?) are supported. table-pattern: "t_*" # The pattern of the data source table name. Wildcard characters (*?) are supported. target-schema: "test" # The name of the downstream TiDB schema. target-table: "t" # The name of the downstream TiDB table. route-rule-2: schema-pattern: "test_*" target-schema: "test"

このページは役に立ちましたか?

Playground
新規
登録なしで TiDB の機能をワンストップでインタラクティブに体験できます。
製品
TiDB Cloud
TiDB
価格
PoC お問い合わせ
エコシステム
TiKV
TiFlash
OSS Insight
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.