Step-by-Step CDC Recovery Guide: Oracle to PostgreSQL Migration
When dealing with AWS DMS CDC failures, you have options for restoring CDC from specific points in time, but there are important constraints:
Recovery Point Options for CDC
Using CdcStartPosition
You can modify a replication task to start from a specific transaction log position
For Oracle, this is an SCN (System Change Number)
For PostgreSQL, it's an LSN (Log Sequence Number)
For MySQL, it's a binary log position
Using CdcStartTime
Instead of a specific log position, you can set a timestamp
DMS will attempt to find the corresponding position in the transaction logs
Example (AWS CLI):
Copyaws dms modify-replication-task \ --replication-task-arn <task-arn> \ --cdc-start-time "2025-01-15T12:00:00Z"
Critical Limitations
Transaction Log Retention
You can only go back as far as your source database retains transaction logs
For Oracle: redo logs and archived logs
For PostgreSQL: WAL segments
For MySQL: binary logs
Log Availability
If logs have been purged or are unavailable, you cannot restart CDC from that point
Many database systems automatically purge older logs
Database-Specific Constraints
Oracle: Requires ARCHIVELOG mode and appropriate retention
PostgreSQL: Requires logical replication slots to be maintained
MySQL: Binary log expiration policy limits recovery points
Best Practices for CDC Recovery
Configure adequate log retention
Extend transaction log retention periods on source databases
For Oracle, ensure ARCHIVELOG mode is enabled with adequate retention
For PostgreSQL, monitor and maintain logical replication slots
For MySQL, set
binlog_expire_logs_secondsappropriately
Create recovery checkpoints
Periodically capture and store the current log position
Consider creating DMS task bookmarks for critical points
Document SCN/LSN positions after major data loads or changes
Implement monitoring for log retention
Monitor source database log space and retention
Set up alerts for log purging events
Track CDC lag metrics in CloudWatch
If logs for your desired recovery point have been purged, your only option would be to perform a new full load and restart CDC from that point. This is why preventive measures like extended log retention are crucial for CDC recovery strategies.
Step-by-step Gide
This guide explains how to set up, maintain, and recover CDC (Change Data Capture) during an Oracle to PostgreSQL migration using AWS DMS.
Part 1: Prerequisites and Configuration
Step 1: Configure Oracle Source for Optimal CDC Recovery
Enable ARCHIVELOG Mode (if not already enabled):
Configure Supplemental Logging:
Configure Adequate Redo Log Retention:
Create a Regular SCN Checkpoint Process:
Monitor Oracle Archive Log Generation:
Step 2: Configure PostgreSQL Target for CDC
Set Up Target PostgreSQL with Appropriate Settings:
Configure PostgreSQL for Performance During CDC:
Step 3: Configure AWS DMS for Recoverable CDC
Create Initial DMS Task with CDC in Mind:
Configure task-settings.json with Logging and Oracle Settings:
Create a Checkpoint Recording Script:
Schedule Checkpoint Script:
Part 2: CDC Recovery Procedures
Step 1: Identifying Available Recovery Points
Check Available Oracle SCN Checkpoints:
Check Available Archive Logs:
Check Minimum Available SCN:
Check Recorded DMS Checkpoints in PostgreSQL:
Step 2: Recover CDC from a Specific SCN
Stop the Current DMS Task:
Modify Task to Start from Specific SCN:
Start Task with New SCN Position:
Monitor CDC Recovery Progress:
Step 3: Recover CDC from a Specific Timestamp
Stop the Current DMS Task:
Find the Nearest SCN for a Timestamp:
Modify Task to Start from a Specific Time:
Start Task with New Time Position:
Verify Recovery Point Success:
Step 4: Handling Recovery Failures
Check for Oracle Archive Log Availability Issues:
Validate SCN Visibility to LogMiner:
If Recovery Point Unavailable, Find Nearest Available SCN:
Create a New Recovery Task if Original Can't Be Recovered:
Part 3: Post-Recovery Validation
Verify Data Consistency After Recovery:
Monitor CDC Performance After Recovery:
Create Regular Data Validation Checks:
Part 4: Automating Recovery for High Availability
Create a CDCMonitor Function in AWS Lambda:
Create Required PostgreSQL Tables for Lambda Function:
Set up CloudWatch Events to Trigger Lambda Function:
This comprehensive guide covers the setup, maintenance, and recovery of CDC during an Oracle to PostgreSQL migration using AWS DMS. The procedures are specifically designed for Oracle on-premises to PostgreSQL on AWS migrations, with an emphasis on establishing reliable recovery points and automating the recovery process.
Part 5: Long-Term CDC Maintenance
Step 1: Database-Side Maintenance
Oracle Archive Log Management:
PostgreSQL Maintenance Procedures:
Step 2: Regular Health Checks
Oracle-side Health Check Script:
PostgreSQL-side Health Check Script:
Step 3: Backup and Disaster Recovery for CDC
Oracle Archive Log Backup Strategy:
PostgreSQL CDC Configuration Backup:
Part 6: Troubleshooting CDC Issues
Common CDC Issues and Solutions
Issue: CDC Task Fails with "ORA-01291: missing logfile"
Solution:
Issue: CDC Latency Increasing
Solution:
Issue: Oracle SCN Jumps Unexpectedly
Solution:
Issue: Inconsistent Data After CDC Recovery
Solution:
This comprehensive guide covers the setup, maintenance, and recovery of CDC during an Oracle to PostgreSQL migration using AWS DMS. The procedures are specifically designed for Oracle on-premises to PostgreSQL on AWS migrations, with an emphasis on establishing reliable recovery points and automating the recovery process.
Last updated
Was this helpful?