AWS Database Migration Service (DMS)
Database Migration Service, SCT, 6Rs Migration Strategies, CDC
Tổng quan
AWS DMS (Database Migration Service) = Service giúp migrate databases từ on-premises, EC2, hoặc RDS sang AWS một cách dễ dàng.
Key Features
| Feature | Mô tả |
|---|---|
| Minimal downtime | Source DB vẫn hoạt động bình thường khi migrate |
| Continuous replication | Sync data liên tục (CDC - Change Data Capture) |
| Homogeneous | Cùng database engine (MySQL → MySQL) |
| Heterogeneous | Khác database engine (Oracle → Aurora) |
| Schema conversion | Tích hợp với SCT để convert schema |
6Rs Migration Strategies
[!IMPORTANT] 6Rs là các strategies để migrate workloads lên Cloud. Đây là kiến thức quan trọng cho exam!
Chi tiết từng Strategy
| Strategy | Ý nghĩa | Effort | Khi nào dùng? |
|---|---|---|---|
| Rehost | Lift & Shift - chuyển nguyên xi | Thấp | Migrate nhanh, không muốn thay đổi |
| Replatform | Thay đổi nhỏ để dùng managed services | Thấp-TB | Muốn giảm operational burden |
| Repurchase | Mua SaaS thay thế | TB | Có SaaS phù hợp, muốn outsource |
| Refactor | Viết lại cloud-native | Cao | Cần tối ưu performance, scalability |
| Retire | Tắt bỏ | Thấp | App không còn giá trị |
| Retain | Giữ on-prem | Không có | Chưa sẵn sàng, quá phức tạp |
Rehost vs Replatform (Hay hỏi trong exam!)
6Rs - Quick Reference
| Keyword trong câu hỏi | Strategy |
|---|---|
| "Move as-is", "no changes" | Rehost |
| "Reduce operational burden", "managed service" | Replatform |
| "Buy new software", "SaaS" | Repurchase |
| "Rewrite", "cloud-native", "microservices" | Refactor |
| "No longer needed", "decommission" | Retire |
| "Keep on-premises", "not ready" | Retain |
Cách hoạt động
Workflow
- Create Replication Instance - EC2 chạy DMS engine
- Create Source/Target Endpoints - Connection settings
- Create Replication Task - Define migration settings
- Start Migration - Full load + CDC (ongoing replication)
- Cutover - Switch app sang target DB (minimal downtime)
Replication Instance là gì?
DMS không phải compute service để bạn chạy application như EC2/Lambda. Nhưng để migrate/replicate database, DMS vẫn cần một compute worker ở giữa source và target. Trong DMS Standard, worker đó gọi là replication instance.
Replication instance dùng để:
- Kết nối source database và target database
- Chạy replication task: full load, CDC, hoặc full load + CDC
- Đọc transaction logs/redo logs để capture
INSERT/UPDATE/DELETE - Buffer/cache khi source nhanh hơn target hoặc network/target bị chậm
- Apply changes sang target theo thứ tự phù hợp
- Ghi metrics/logs/checkpoint để theo dõi và resume migration
Vì vậy với DMS Standard, bạn phải chọn size cho replication instance, ví dụ:
Nếu chọn quá nhỏ → full load chậm, CDC lag, thiếu memory, task có thể fail. Nếu chọn quá lớn → tốn chi phí khi workload thấp.
Replication trong DMS nghĩa là gì?
Trong DMS, replication là quá trình DMS copy/sync dữ liệu từ source sang target. Nó không nhất thiết là native database replication như Oracle Data Guard.
| Replication type | Ý nghĩa | Use case |
|---|---|---|
| Full load | Copy dữ liệu hiện có từ source sang target | Initial migration |
| CDC | Capture thay đổi mới phát sinh từ transaction logs | Continuous sync |
| Full load + CDC | Copy dữ liệu hiện có và đồng thời capture thay đổi mới | Minimal downtime migration |
AWS DMS Serverless
AWS DMS Serverless = mode DMS không cần tự chọn/sizing replication instance như DMS Standard. AWS DMS ẩn phần compute worker bên dưới, tự tính toán, provision và scale replication resources dựa trên workload thực tế.
Dùng khi câu hỏi nhấn mạnh:
- Full load + CDC nhưng workload/throughput dao động
- Không muốn quản lý replication instance
- Muốn compute tự động scale theo migration/replication workload
- Cần migrate/replicate database với operational burden thấp hơn DMS Standard
📖 Nguồn: Working with AWS DMS Serverless
DMS Standard vs DMS Serverless
| Tiêu chí | DMS Standard | DMS Serverless |
|---|---|---|
| Compute | Chọn replication instance chạy replication engine | Chọn Min/Max DCU |
| Sizing | Bạn tự estimate instance size (dms.r5.large, dms.r5.xlarge, ...) | DMS tự compute/provision capacity |
| Scaling | Phải monitor và resize | Autoscaling trong giới hạn cấu hình |
| Ops burden | Cao hơn | Thấp hơn |
| Phù hợp | Workload ổn định, predictable | Workload dao động, muốn managed scaling |
| Billing | Theo replication instance | Pay-for-use theo DCU đang dùng |
DMS Capacity Unit (DCU)
Với DMS Serverless, bạn cấu hình Compute Config bằng:
| Setting | Ý nghĩa |
|---|---|
| MinCapacityUnits | Số DCU tối thiểu DMS provision; cũng là mức scale-down thấp nhất |
| MaxCapacityUnits | Số DCU tối đa DMS có thể provision; cũng là mức scale-up cao nhất |
| MultiAZ | Tạo standby replica ở AZ khác để failover; AWS khuyến nghị bật nếu dùng CDC/ongoing replication |
AWS định nghĩa 1 DCU = 2 GB RAM. DMS tính phí theo số DCU replication đang dùng.
Replication phases trong DMS Serverless
DMS Serverless vẫn hỗ trợ các kiểu replication quan trọng của DMS:
| Phase / Type | Ý nghĩa | Khi nào dùng? |
|---|---|---|
| Full load | Copy dữ liệu hiện có tại thời điểm bắt đầu replication | Initial migration |
| CDC initial | Copy các thay đổi xảy ra trong lúc full load đang chạy | Bắt kịp source DB sau full load |
| CDC ongoing | Tiếp tục replicate thay đổi khi chúng xảy ra | Near-zero downtime / continuous replication |
| Full load and CDC | Migrate dữ liệu hiện có + thay đổi phát sinh trong quá trình replication | Pattern hay gặp nhất khi migrate DB đang chạy |
Autoscaling hoạt động thế nào?
Sau khi replication ở trạng thái RUNNING, AWS DMS quản lý capacity của underlying resources để thích ứng với workload thay đổi.
- Workload tăng vượt threshold → DMS có thể scale up replication resources
- Workload giảm đủ lâu → DMS có thể scale down để tiết kiệm chi phí
- Scaling bị giới hạn bởi MinCapacityUnits và MaxCapacityUnits
- Serverless replication không autoscale down trong khi full load đang chạy
Supported endpoints
DMS Serverless hỗ trợ nhiều source/target, bao gồm Oracle ở cả hai phía:
| Vai trò | Ví dụ supported endpoints |
|---|---|
| Sources | Oracle, SQL Server, PostgreSQL-compatible, MySQL-compatible, MariaDB, MongoDB, Amazon S3, IBM Db2 |
| Targets | Oracle, SQL Server, PostgreSQL, MySQL-compatible, Amazon S3, Redshift, DynamoDB, Kinesis Data Streams, MSK, OpenSearch, Neptune |
Ví dụ exam:
Khi nào chọn DMS Serverless?
| Keyword trong đề | Đáp án nên nghĩ tới |
|---|---|
| "automatically provision compute resources" | DMS Serverless |
| "workload fluctuates" / "spikes in transaction volume" | DMS Serverless autoscaling |
| "existing records and ongoing changes" | Full load + CDC |
| "Oracle on-premises to RDS for Oracle" | DMS homogeneous migration/replication |
| "reduce replication instance management" | DMS Serverless |
Lưu ý dễ sai
- DMS Serverless không phải Lambda: Lambda không phải managed CDC engine cho database transaction logs.
- DMS Serverless không phải Glue: Glue phù hợp ETL/batch/data integration, không phải lựa chọn chính cho transactional CDC migration.
- DMS Serverless không phải EC2 Auto Scaling: bạn không tự deploy DMS replication instance trên EC2 rồi scale bằng script; DMS quản lý replication resources.
- Replication instance không phải app server: nó là worker managed bởi DMS để chạy replication engine, đọc source logs, buffer dữ liệu và ghi sang target.
- Nếu target là cùng engine như Oracle → RDS Oracle: thường không cần SCT, vì đây là homogeneous migration.
Migration Types
1. Homogeneous Migration (Cùng engine)
Source và Target cùng database engine → Không cần convert schema.
2. Heterogeneous Migration (Khác engine)
Source và Target khác database engine → CẦN convert schema trước.
Supported Databases
Sources (Nguồn)
| Category | Databases |
|---|---|
| On-premises | Oracle, SQL Server, MySQL, PostgreSQL, MariaDB, SAP, MongoDB |
| AWS | RDS (all engines), Aurora, S3, DocumentDB |
| Cloud | Azure SQL, Azure MySQL, Azure PostgreSQL |
Targets (Đích)
| Category | Databases |
|---|---|
| Relational | RDS, Aurora, Redshift, Oracle, SQL Server, MySQL, PostgreSQL |
| NoSQL | DynamoDB, DocumentDB, Neptune |
| Data Lake | S3 (Parquet, CSV, JSON) |
| Streaming | Kinesis Data Streams |
| Search | OpenSearch Service |
AWS Schema Conversion Tool (SCT)
AWS SCT = Tool convert database schema từ một engine sang engine khác.
SCT Features
| Feature | Mô tả |
|---|---|
| Assessment Report | Phân tích độ phức tạp của migration |
| Auto-convert | Tự động convert ~80-90% schema |
| Manual fixes | Highlight code cần sửa manual |
| Data extraction agents | Extract data từ data warehouses |
DMS vs SCT
| AWS DMS | AWS SCT | |
|---|---|---|
| Purpose | Migrate DATA | Convert SCHEMA |
| When to use | Mọi database migration | Chỉ khi heterogeneous migration |
| Output | Data trong target DB | SQL scripts cho schema |
| Runs on | AWS Cloud (Replication Instance hoặc Serverless Replication) | Local machine (Desktop app) |
| Cost | Pay for replication instance hoặc DMS Serverless DCU | FREE |
Khi nào dùng cái nào?
Use Cases
1. On-Premises to AWS
2. Cloud to Cloud
3. Consolidation
4. Continuous Replication (CDC)
Pricing
| Component | Pricing |
|---|---|
| Replication Instance | Per hour (like EC2) |
| DMS Serverless DCU | Pay-for-use theo DMS Capacity Units đang dùng |
| Storage | Per GB-month |
| Data Transfer | Standard AWS data transfer rates |
| SCT | FREE |
Instance sizing
| Size | vCPU | Memory | Use case |
|---|---|---|---|
| dms.t3.micro | 2 | 1 GB | Testing |
| dms.t3.medium | 2 | 4 GB | Small workloads |
| dms.r5.large | 2 | 16 GB | Production |
| dms.r5.xlarge | 4 | 32 GB | Large production |
Exam Tips
[!IMPORTANT] DMS = Migrate DATABASE với minimal downtime. SCT = Convert SCHEMA khi khác engine.
Keyword → Answer
| Keyword trong câu hỏi | Đáp án |
|---|---|
| "Migrate database to AWS" | AWS DMS |
| "Minimal downtime migration" | AWS DMS |
| "Continuous replication" | AWS DMS (CDC) |
| "Convert Oracle to Aurora" | AWS SCT (schema) + DMS (data) |
| "Same engine migration" | DMS only |
| "Different engine migration" | SCT + DMS |
| "Automatically provision compute resources" | DMS Serverless |
| "Data transfer volume fluctuates" | DMS Serverless |
Key Points
- DMS = Migrate DATA
- SCT = Convert SCHEMA (FREE, runs locally)
- Homogeneous (same engine) = DMS only
- Heterogeneous (different engine) = SCT + DMS
- Source DB không downtime khi migration
- CDC = Change Data Capture (continuous sync)
- DMS Serverless = DMS tự provision/scale replication resources, không cần tự chọn replication instance
- Full load + CDC + workload dao động = DMS Serverless
Common Scenarios
| Scenario | Solution |
|---|---|
| "Migrate MySQL to RDS MySQL" | DMS only |
| "Migrate Oracle to Aurora PostgreSQL" | SCT + DMS |
| "Keep data synced during migration" | DMS with CDC |
| "Existing data + ongoing changes + fluctuating volume" | DMS Serverless Full load + CDC |
| "Migrate to data lake (S3)" | DMS to S3 |
| "Migrate data warehouse to Redshift" | SCT (data extraction) + DMS |