This is 2nd article on Database Migration Steps using AWS CLI, showing on how to set up a replication task
. The replication task runs on the replication instance and migrates data from the source endpoint to the target endpoint.
Please read my 1st article, Database Migration steps with the AWS CLI - 1, where I have shown on how to create and set up a replication instance, source and target endpoints.
You can use the AWS DMS console or the AWS CLI or the AWS SDK to perform the database migration.
Please visit my GitHub Repository for Database Migration articles on various topics being updated on constant basis.
Letβs get started!
Objectives:
6. Create a replication task.
7. Describe the replication task.
8. Start the replication task.
9. Check the progress of the replication task.
10. Stop the replication task.
11. Delete the replication task.
12. Delete the source and target endpoints.
13. Delete the replication instance.
Pre-requisites:
- AWS user account with admin access, not a root account.
- Cloud9 IDE with AWS CLI.
Resources Used:
AWS Database Migration Service
AWS CLI Command Reference on DMS
Steps for implementation to this project:
6. Create a replication task.
- If the test connections are successful, use the following command to create the task:
aws dms create-replication-task --replication-task-identifier replication-task-1 --source-endpoint-arn $source_endpoint_arn --target-endpoint-arn $target_endpoint_arn --replication-instance-arn $rep_instance_arn --migration-type full-load --table-mappings file:///tmp/table-mappings --replication-task-settings file:///tmp/task-settings
Create table mappings and task settings files in the temp directory (in Linux).
For Loading Parameters, read from Loading Parameters from a File
For task settings, read from Task Settings for AWS Database Migration Service Tasks
For migration methods, read from Migration Methods for AWS Database Migration Service
Read from for Table Mapping to specify task settings
Wait for 4-5 minutes to complete the tsk creation.
7. Describe the replication task.
- After the task is created, describe the task to check that it is ready to be executed.
aws dms describe-replication-tasks --filters "Name=replication-task-id,Values=replication-task-1"
- Run the following command to save the replication task ARN for use in later steps:
replication task ARN
replication_task_arn=$(aws dms describe-replication-tasks --filters "Name= replication-task-id,Values=replication-task-1" --query "ReplicationTasks[0].ReplicationTaskArn" --output text)
- Run the following command to check the status of the task:
aws dms describe-replication-tasks --filters "Name=replication-task-arn,Values=$replication_task_arn" --query "ReplicationTasks[0].Status"
8. Start the replication task.
- Run the following command to start the task:
aws dms start-replication-task --replication-task-arn $replication_task_arn --start-replication-task-type start-replication
- Read for start-replication-task command
9. Check the progress of the replication task.
Run the following commands to keep track of the task progress.
To monitor the overall task-level statistics, run the following command:
aws dms describe-replication-tasks --filters "Name=replication-task-arn,Values=$replication_task_arn" --query "ReplicationTasks[0].ReplicationTaskStats"
- To monitor the table-level statistics, run the following command:
aws dms describe-table-statistics --replication-task-arn $replication_task_arn
- To monitor the task status itself, run the following command:
aws dms describe-replication-tasks --filters "Name=replication-task-arn,Values=$replication_task_arn" --query "ReplicationTasks[0].{Status:Status,StopReason:StopReason}"
10. Stop the replication task.
You can stop the migration after data is completely migrated from source to target.
Run the following command to stop the migration task:
aws dms stop-replication-task --replication-task-arn $replication_task_arn
Cleanup
11. Delete the replication task.
- Run the following command to delete it:
aws dms delete-replication-task --replication-task-arn $replication_task_arn
12. Delete the source and target endpoints.
- Run the following commands to delete them:
aws dms delete-endpoint --endpoint-arn $source_endpoint_arn
aws dms delete-endpoint --endpoint-arn $target_endpoint_arn
13. Delete the replication instance.
- Run the following command to delete the replication instance:
aws dms delete-replication-instance --replication-instance-arn $rep_instance_arn
What we have done so far
We have successfully demonstrated on how to set up a replication task
.
Top comments (0)