CLI로 CreateReplicationTask 사용 - AWS SDK 코드 예제

AWS SDK 예제 GitHub 리포지토리에 더 많은 AWS문서 SDK 예제가 있습니다.

CLI로 CreateReplicationTask 사용

다음 코드 예시는 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 사용 설명서Working with AWS DMS Tasks를 참조하세요.

PowerShell
Tools for PowerShell V4

예제 1: 이 예제에서는 CdcStartPosition 대신 CdcStartTime을 사용하는 새 AWS Database Migration Service 복제 작업을 생성합니다. MigrationType은 'full-load-and-cdc'로 설정되어 있습니다. 즉, 대상 테이블이 비어 있어야 합니다. 새 작업에는 키가 Stage이고 키 값이 Test인 태그가 지정됩니다. 이 cmdlet에서 사용하는 값에 대한 자세한 내용은 AWS Database Migration Service 사용 설명서의 작업 생성(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 참조(V4)CreateReplicationTask를 참조하세요.

Tools for PowerShell V5

예제 1: 이 예제에서는 CdcStartPosition 대신 CdcStartTime을 사용하는 새 AWS Database Migration Service 복제 작업을 생성합니다. MigrationType은 'full-load-and-cdc'로 설정되어 있습니다. 즉, 대상 테이블이 비어 있어야 합니다. 새 작업에는 키가 Stage이고 키 값이 Test인 태그가 지정됩니다. 이 cmdlet에서 사용하는 값에 대한 자세한 내용은 AWS Database Migration Service 사용 설명서의 작업 생성(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 참조(V5)CreateReplicationTask를 참조하세요.