创建 TiDB Data Migration 数据迁移任务
start-task 命令用于创建数据迁移任务。当数据迁移任务启动时,TiDB Data Migration (DM) 将自动对相应权限和配置进行前置检查。
1. help start-task
1. Starts a task as defined in the configuration file
3. Usage:
4. dmctl start-task [-s source ...] [--remove-meta] <config-file> [flags]
6. Flags:
7. -h, --help help for start-task
8. --remove-meta whether to remove task's meta data
9. --start-time string specify the start time of binlog replication, e.g. '2021-10-21 00:01:00' or 2021-10-21T00:01:00
11. Global Flags:
12. --config string Path to config file.
13. --master-addr string Master API server address, this parameter is required when interacting with the dm-master
14. --rpc-timeout string RPC timeout, default is 10m. (default "10m")
15. -s, --source strings MySQL Source ID.
16. --ssl-ca string Path of file that contains list of trusted SSL CAs for connection.
17. --ssl-cert string Path of file that contains X509 certificate in PEM format for connection.
18. --ssl-key string Path of file that contains X509 key in PEM format for connection.
19. -V, --version Prints version and exit.
命令用法示例
1. start-task [ -s "mysql-replica-01"] ./task.yaml
参数解释
-s:- 可选
- 指定在特定的一个 MySQL 源上执行
task.yaml - 如果设置,则只启动指定任务在该 MySQL 源上的子任务
config-file:- 必选
- 指定
task.yaml的文件路径 remove-meta:- 可选
- 如果设置,则在启动指定任务时会移除该任务之前存在的 metadata
start-time:- 可选,格式为
'2021-10-21 00:01:00'或2021-10-21T00:01:00 - 对于增量任务,可以通过该参数大致指定任务起始位点,该参数比任务配置文件中的 binlog 位置优先级更高,也比下游 checkpoint 中的 binlog 位置优先级更高
- 当该任务存在 checkpoint 时,如果通过这种方式启动任务,DM 会自动开启 safe mode 直到同步过 checkpoint,以避免重置任务到更早位置时遇到数据重复的报错。向前重置起始位点时,如果起始位点的表结构与下游当前表结构不一致可能会在同步时报错;向后重置起始位点时,需要注意跳过的 binlog 可能在下游残留脏数据
- 指定了过早的时间时,会从最早的 binlog 开始同步
- 指定了过晚的时间时,会报错
start-time {input-time} is too late, no binlog location matches it
返回结果示例
1. start-task task.yaml
1. {
2. "result": true,
3. "msg": "",
4. "sources": [
5. {
6. "result": true,
7. "msg": "",
8. "source": "mysql-replica-01",
9. "worker": "worker1"
10. }
11. ]
12. }
