CreateReplicationTask 搭配 使用 CLI - AWS SDK 程式碼範例

文件範例儲存庫中有更多 AWS SDK可用的範例。 AWS SDK GitHub

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

CreateReplicationTask 搭配 使用 CLI

下列程式碼範例示範如何使用 CreateReplicationTask

CLI
AWS CLI

建立複寫任務

下列create-replication-task範例會建立複寫任務。

aws dms create-replication-task \ --replication-task-identifier movedata \ --source-endpoint-arn arn:aws:dms:us-east-1:123456789012:endpoint:6GGI6YPWWGAYUVLKIB732KEVWA \ --target-endpoint-arn arn:aws:dms:us-east-1:123456789012:endpoint:EOM4SFKCZEYHZBFGAGZT3QEC5U \ --replication-instance-arn $RI_ARN \ --migration-type full-load \ --table-mappings file://table-mappings.json

table-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任務

PowerShell
適用於 的工具 PowerShell

範例 1:此範例會建立新的 AWS Database Migration Service 複寫任務,使用 CdcStartTime 而非 CdcStartPosition。 MigrationType 設定為「full-load-and-cdc」,表示目標資料表必須為空白。新任務會標記具有 Stage 金鑰和 Test 金鑰值的標籤。如需此 cmdlet 使用值的詳細資訊,請參閱 AWS 資料庫遷移服務使用者指南中的建立任務 (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 參考 CreateReplicationTask中的 。