📣
TiDB Cloud Premium はパブリックプレビュー中です。エンタープライズワークロード向けの無制限のスケーリング、即時の弾力性、高度なセキュリティを提供します。このページは自動翻訳されたものです。原文はこちらからご覧ください。

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



このドキュメントでは、Data Migration (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イベントのフィルターを構成するには、次の手順を実行します。

  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 テーブルに移行するためのルーティング マッピング ルールを構成するには、次の手順を実行します。

  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.

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

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

--- ## ********* 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"

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