AWS 文档 SDK 示例
将 CreateReplicationTask 与 CLI 配合使用
以下代码示例演示如何使用 CreateReplicationTask。
- CLI
-
- AWS CLI
-
创建复制任务
以下
create-replication-task示例创建复制任务。aws dms create-replication-task \ --replication-task-identifiermovedata\ --source-endpoint-arnarn:aws:dms:us-east-1:123456789012:endpoint:6GGI6YPWWGAYUVLKIB732KEVWA\ --target-endpoint-arnarn:aws:dms:us-east-1:123456789012:endpoint:EOM4SFKCZEYHZBFGAGZT3QEC5U\ --replication-instance-arn$RI_ARN\ --migration-typefull-load\ --table-mappingsfile://table-mappings.jsontable-mappings.json的内容:{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "prodrep", "table-name": "%" }, "rule-action": "include", "filters": [] } ] }输出:
{ "ReplicationTask": { "ReplicationTaskIdentifier": "moveit2", "SourceEndpointArn": "arn:aws:dms:us-east-1:123456789012:endpoint:6GGI6YPWWGAYUVLKIB732KEVWA", "TargetEndpointArn": "arn:aws:dms:us-east-1:123456789012:endpoint:EOM4SFKCZEYHZBFGAGZT3QEC5U", "ReplicationInstanceArn": "arn:aws:dms:us-east-1:123456789012:rep:T3OM7OUB5NM2LCVZF7JPGJRNUE", "MigrationType": "full-load", "TableMappings": ...output omitted... , "ReplicationTaskSettings": ...output omitted... , "Status": "creating", "ReplicationTaskCreationDate": 1590524772.505, "ReplicationTaskArn": "arn:aws:dms:us-east-1:123456789012:task:K55IUCGBASJS5VHZJIINA45FII" } }有关更多信息,请参阅《AWS Database Migration Service 用户指南》中的使用 AWS DMS 任务。
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CreateReplicationTask
。
-
- PowerShell
-
- Tools for PowerShell V4
-
示例 1:此示例创建一个新的 AWS Database Migration Service 复制任务,该任务使用 CdcStartTime 而不是 CdcStartPosition。MigrationType 设置为“full-load-and-cdc”,这意味着目标表必须为空。新任务使用一个标签进行标记,该标签的键为 Stage,键值为 Test。有关此 cmdlet 使用的值的更多信息,请参阅《AWS Database Migration Service User Guide》中的“Creating a Task”(https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.Creating.html)。
New-DMSReplicationTask -ReplicationInstanceArn "arn:aws:dms:us-east-1:123456789012:rep:EXAMPLE66XFJUWATDJGBEXAMPLE"` -CdcStartTime "2019-08-08T12:12:12"` -CdcStopPosition "server_time:2019-08-09T12:12:12"` -MigrationType "full-load-and-cdc"` -ReplicationTaskIdentifier "task1"` -ReplicationTaskSetting ""` -SourceEndpointArn "arn:aws:dms:us-east-1:123456789012:endpoint:EXAMPLEW5UANC7Y3P4EEXAMPLE"` -TableMapping "file:////home/testuser/table-mappings.json"` -Tag @{"Key"="Stage";"Value"="Test"}` -TargetEndpointArn "arn:aws:dms:us-east-1:123456789012:endpoint:EXAMPLEJZASXWHTWCLNEXAMPLE"-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V4)》中的 CreateReplicationTask。
-
- Tools for PowerShell V5
-
示例 1:此示例创建一个新的 AWS Database Migration Service 复制任务,该任务使用 CdcStartTime 而不是 CdcStartPosition。MigrationType 设置为“full-load-and-cdc”,这意味着目标表必须为空。新任务使用一个标签进行标记,该标签的键为 Stage,键值为 Test。有关此 cmdlet 使用的值的更多信息,请参阅《AWS Database Migration Service User Guide》中的“Creating a Task”(https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.Creating.html)。
New-DMSReplicationTask -ReplicationInstanceArn "arn:aws:dms:us-east-1:123456789012:rep:EXAMPLE66XFJUWATDJGBEXAMPLE"` -CdcStartTime "2019-08-08T12:12:12"` -CdcStopPosition "server_time:2019-08-09T12:12:12"` -MigrationType "full-load-and-cdc"` -ReplicationTaskIdentifier "task1"` -ReplicationTaskSetting ""` -SourceEndpointArn "arn:aws:dms:us-east-1:123456789012:endpoint:EXAMPLEW5UANC7Y3P4EEXAMPLE"` -TableMapping "file:////home/testuser/table-mappings.json"` -Tag @{"Key"="Stage";"Value"="Test"}` -TargetEndpointArn "arn:aws:dms:us-east-1:123456789012:endpoint:EXAMPLEJZASXWHTWCLNEXAMPLE"-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V5)》中的 CreateReplicationTask。
-