Aurora PostgreSQL 跨账号跨 Region 同步与迁移

验证:未记录
适用版本
未记录
验证范围
尚未登记验证记录。

本文缩写(英文全称与中文含义)
缩写 英文全称/名称 中文含义
API Application Programming Interface 应用程序编程接口
ARN Amazon Resource Name AWS 资源名称,用于唯一标识资源
AWS Amazon Web Services 亚马逊云服务
CDC Change Data Capture 变更数据捕获
CLI Command-Line Interface 命令行接口
CPU Central Processing Unit 中央处理器
DB Database 数据库
DDL Data Definition Language 数据定义语言,如建表、修改表结构
DML Data Manipulation Language 数据操作语言,如插入、更新、删除数据
DMS Database Migration Service 数据库迁移服务
DNS Domain Name System 域名系统
IAM Identity and Access Management 身份与访问管理
ID Identifier 标识符
IOPS Input/Output Operations Per Second 每秒输入输出操作数
KMS Key Management Service 密钥管理服务
PK Primary Key 主键
RDS Relational Database Service AWS 关系型数据库服务
RLS Row-Level Security 行级安全
S3 Simple Storage Service AWS 对象存储服务
SCT Schema Conversion Tool AWS 数据库结构转换工具
SQL Structured Query Language 结构化查询语言
TCP Transmission Control Protocol 传输控制协议
TLS Transport Layer Security 传输层安全协议
TOAST The Oversized-Attribute Storage Technique PostgreSQL 超大字段存储机制
VPC Virtual Private Cloud 虚拟私有云网络
VPN Virtual Private Network 虚拟专用网络
WAL Write-Ahead Log 预写日志

1. 能力边界与方案选择#

目标:将 Account A / Region A 中的 Aurora PostgreSQL source cluster A1 迁移或持续同步到 Account B / Region B 的 destination cluster B2。

Requirement Recommended solution Downtime Important limitation
同账号跨 Region managed replication Aurora Global Database low global cluster resources 属于同一个 AWS account,不是跨账号复制方案
跨账号整 cluster 一次性迁移 Manual cluster snapshot share/copy/restore medium/high engine/version compatibility、KMS 和 snapshot ownership 必须满足
跨账号选择 database/schema/table pg_dump + pg_restore medium/high dump/restore 时间进入停机窗口,没有后续 CDC
跨账号低停机迁移 AWS DMS full load + CDC low schema objects、DDL、sequence、LOB 和冲突需要单独处理
跨账号长期单向 table replication Native PostgreSQL logical replication low after setup 自行运维 publication/subscription、slot、DDL 和冲突
跨账号备份恢复 AWS Backup cross-account/cross-Region copy restore-based 不是 near-real-time replication
Aurora Global Database:
    good for same-account cross-Region architecture
    not a direct Account A -> Account B replication mechanism

RDS/Aurora snapshot export to S3:
    produces analytics files such as Parquet
    cannot be restored directly as an Aurora cluster
    not a replacement for snapshot restore, pg_restore, or DMS

推荐默认:

can stop for hours and wants full cluster copy:
    snapshot copy/share/restore

can stop and needs selective/version-changing migration:
    pg_dump/pg_restore

cannot stop for full copy duration:
    DMS full load + CDC

needs permanent table-level replication and accepts PostgreSQL operations:
    native logical replication

2. 迁移前盘点#

不要只记录 cluster endpoint。至少收集:

source:
    Account ID and Region
    cluster identifier and ARN
    Aurora PostgreSQL engine version
    instance classes and topology
    database names and total size
    schemas, tables, partitions, indexes, constraints
    extensions and extension versions
    roles, grants, row-level security
    functions, procedures, triggers, views, materialized views
    sequences and identity columns
    large objects and large columns
    parameter group and cluster parameter group
    storage encryption KMS key
    Secrets Manager secret and authentication mode
    logical replication / replication slots

target:
    Account ID and Region
    target engine version
    subnet group, VPC, security groups
    parameter groups
    customer managed KMS key
    instance classes and capacity
    backup retention, deletion protection, monitoring
    application cutover endpoint/secret

Basic source checks:

SELECT version();
SELECT current_database();
SELECT pg_size_pretty(pg_database_size(current_database()));

SELECT extname, extversion
FROM pg_extension
ORDER BY extname;

SELECT schemaname, relname, n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;

SELECT slot_name, plugin, slot_type, active, restart_lsn
FROM pg_replication_slots;

AWS checks:

aws rds describe-db-clusters --profile account-a --region ap-east-1 --db-cluster-identifier A1

aws rds describe-db-cluster-parameters --profile account-a --region ap-east-1 --db-cluster-parameter-group-name SOURCE-CLUSTER-PARAMETER-GROUP

3. 停机整 Cluster:Snapshot Share/Copy/Restore#

Snapshot 适合 source 和 target 使用兼容 Aurora PostgreSQL engine/version,并且希望迁移 database data、indexes、schema objects 和 database roles 的整 cluster 场景。

选择正确的 snapshot 类型#

Aurora PostgreSQL 必须选择 DB cluster snapshot,不是 DB instance snapshot:

Aurora PostgreSQL:
    DB cluster snapshot
    CLI = create-db-cluster-snapshot

standard RDS PostgreSQL:
    DB instance snapshot
    CLI = create-db-snapshot

Aurora data 存储在 cluster shared volume 中,writer/reader DB instances 是独立 compute resources。DB cluster snapshot 保护 cluster storage;它不会保存并自动重建原 writer/reader instance identifiers、instance classes 和 instance count。

迁移时选择 Take snapshot / Create DB cluster snapshot,不要选择 Export snapshot to S3:

Take DB cluster snapshot:
    creates a restorable Aurora snapshot
    can be copied/shared/restored as a cluster

Export snapshot to S3:
    writes analytics-oriented files such as Parquet
    cannot be restored directly as Aurora PostgreSQL

推荐顺序:

1. stop all application writes
2. create manual DB cluster snapshot in Account A
3. wait until snapshot status = available
4. copy snapshot to destination Region when required
5. share manual snapshot with Account B
6. share source customer managed KMS key permissions when encrypted
7. Account B copies shared snapshot using its own KMS key
8. Account B restores a new Aurora cluster from its owned snapshot
9. recreate networking, parameter groups, monitoring, secrets, IAM integration
10. validate and switch application

Create manual cluster snapshot:

aws rds create-db-cluster-snapshot --profile account-a --region ap-east-1 --db-cluster-identifier A1 --db-cluster-snapshot-identifier a1-migration-20260824

Check status:

aws rds describe-db-cluster-snapshots --profile account-a --region ap-east-1 --db-cluster-snapshot-identifier a1-migration-20260824 --query 'DBClusterSnapshots[0].{Status:Status,Engine:Engine,EngineVersion:EngineVersion,Encrypted:StorageEncrypted,KmsKeyId:KmsKeyId}'

Snapshot Storage 字段#

Aurora snapshot 页面/API 中的 Storage 或 AllocatedStorage 不应当作实际 database content size。Aurora storage 自动扩展,没有普通 RDS 那种固定 allocated storage;某些 API/Console 视图中 Aurora AllocatedStorage 可能显示 1 GiB 占位值。

do not use:
    Aurora snapshot AllocatedStorage as database size

use instead:
    CloudWatch AWS/RDS VolumeBytesUsed for cluster volume usage
    PostgreSQL pg_database_size() for logical database size

查看 PostgreSQL logical size:

SELECT
  datname,
  pg_size_pretty(pg_database_size(datname)) AS size
FROM pg_database
WHERE datistemplate = false
ORDER BY pg_database_size(datname) DESC;

pg_database_size() 包含 database 中的 table、index、TOAST 等逻辑占用;VolumeBytesUsed 更接近 Aurora cluster volume 实际计费存储。Snapshot 本身使用增量 backup 机制,snapshot 存储计费也不等于 Console 的 AllocatedStorage 字段。

Share the manual snapshot with Account B after it is in the Region from which it will be shared:

aws rds modify-db-cluster-snapshot-attribute --profile account-a --region ap-southeast-1 --db-cluster-snapshot-identifier a1-migration-20260824 --attribute-name restore --values-to-add 222222222222

Important encryption rules:

unencrypted manual snapshot:
    can be shared

snapshot encrypted with customer managed KMS key:
    can be shared when Account B is allowed to use the key
    Account B should copy it with an Account B KMS key before restore

snapshot encrypted with AWS managed key aws/rds:
    cannot be shared cross-account directly
    copy/re-encrypt with a customer managed key first

For cross-Region + cross-account, design both copies explicitly. A common sequence is:

Account A source Region snapshot
    -> Account A copy to destination Region using Account A customer managed KMS key
    -> share destination-Region snapshot and KMS permission with Account B
    -> Account B copy shared snapshot using Account B destination-Region KMS key
    -> Account B restore cluster

Snapshot sharing 是 Region-scoped。AWS account 本身没有 Region,但 Account B 只能在 snapshot 所在 Region 的 Shared with me 中看到它,不能从另一个 Region 直接看到同一份 shared snapshot。

recommended:
    Account A / source Region snapshot
    -> Account A copy to target Region
    -> Account A shares target-Region snapshot with Account B
    -> Account B sees it in target Region
    -> Account B copies it with Account B KMS key

possible but usually more complex:
    Account A shares in source Region
    -> Account B sees it in source Region
    -> Account B performs cross-Region copy

推荐 Account A 先 copy 到 target Region 再 share,这样 snapshot ARN、KMS key、Console Region 和最终 restore Region 更容易保持一致。

Account B must still create or select:

DB subnet group
security groups
cluster and instance parameter groups
DB instance classes
Secrets Manager integration
enhanced monitoring / Performance Insights / log exports
backup retention and deletion protection
Route 53 or application configuration

Snapshot restore creates a new cluster. It does not overwrite an existing B2, and it does not preserve source endpoints, VPC resources, CloudWatch alarms or application secrets.

Account B Restore Aurora Cluster#

前提:Account B 已将 shared snapshot copy 成自己拥有的 manual DB cluster snapshot,并且状态为 available。加密 snapshot 应已经使用 Account B / target Region 的 customer managed KMS key。

确认 Account B snapshot:

aws rds describe-db-cluster-snapshots --profile account-b --region ap-southeast-1 --snapshot-type manual --query 'DBClusterSnapshots[].{ID:DBClusterSnapshotIdentifier,ARN:DBClusterSnapshotArn,Status:Status,Engine:Engine,Version:EngineVersion,Encrypted:StorageEncrypted,KmsKeyId:KmsKeyId}'

Restore 分成两个资源步骤:

restore-db-cluster-from-snapshot:
    restores Aurora cluster storage and cluster metadata
    does not create a usable writer DB instance by itself in the CLI flow

create-db-instance:
    creates the Aurora compute instance inside B2
    first available instance becomes the writer

只完成 CLI restore-db-cluster-from-snapshot 后,典型状态是:

B2 DB cluster:
    shared cluster storage restored
    database/schema/table/index/sequence data restored
    cluster endpoint metadata may exist

compute topology:
    DBClusterMembers = []
    no writer instance
    no reader instance
    PostgreSQL endpoint cannot serve normal connections

检查 cluster members:

aws rds describe-db-clusters --profile account-b --region ap-southeast-1 --db-cluster-identifier B2 --query 'DBClusters[0].DBClusterMembers'

返回 [] 时必须创建至少一个 DB instance。第一个可用 instance 成为 writer;后续 instances 成为 readers/failover candidates。Console Restore wizard 通常会让用户选择 instance class,并在同一工作流中创建第一个 writer,所以 Console 看起来可能没有独立的第二步,但底层仍然同时需要 cluster storage 和 compute instance。

先在 Account B 准备:

DB subnet group in the target VPC
security group allowing approved PostgreSQL clients on TCP 5432
Aurora PostgreSQL cluster parameter group matching the engine family
Aurora PostgreSQL DB parameter group matching the engine family
target DB instance class

Restore cluster storage:

aws rds restore-db-cluster-from-snapshot --profile account-b --region ap-southeast-1 --db-cluster-identifier B2 --snapshot-identifier arn:aws:rds:ap-southeast-1:222222222222:cluster-snapshot:a1-migration-account-b-copy --engine aurora-postgresql --db-subnet-group-name account-b-aurora-subnets --vpc-security-group-ids sg-0123456789abcdef0 --db-cluster-parameter-group-name aurora-postgresql-target-cluster --port 5432 --copy-tags-to-snapshot --enable-cloudwatch-logs-exports postgresql --deletion-protection

Snapshot 已经使用 Account B KMS key 加密时,restore 会继承 snapshot encryption,不需要再次指定 --kms-key-id。不要在 restore 时随意指定不同 engine major version;先按 AWS 支持矩阵确认 snapshot restore/upgrade 路径和 parameter group family。

等待 cluster storage available:

aws rds wait db-cluster-available --profile account-b --region ap-southeast-1 --db-cluster-identifier B2

设置 restore API 不接受的运行配置,例如 backup retention:

aws rds modify-db-cluster --profile account-b --region ap-southeast-1 --db-cluster-identifier B2 --backup-retention-period 7 --apply-immediately

创建 writer DB instance:

aws rds create-db-instance --profile account-b --region ap-southeast-1 --db-instance-identifier b2-writer-1 --db-cluster-identifier B2 --engine aurora-postgresql --db-instance-class db.r7g.large --db-parameter-group-name aurora-postgresql-target-instance --promotion-tier 0 --no-publicly-accessible --enable-performance-insights
aws rds wait db-instance-available --profile account-b --region ap-southeast-1 --db-instance-identifier b2-writer-1

需要 reader 时再创建 additional Aurora instances。Reader 使用相同 cluster identifier,不同 instance identifier,并设置合适的 promotion tier:

aws rds create-db-instance --profile account-b --region ap-southeast-1 --db-instance-identifier b2-reader-1 --db-cluster-identifier B2 --engine aurora-postgresql --db-instance-class db.r7g.large --db-parameter-group-name aurora-postgresql-target-instance --promotion-tier 1 --no-publicly-accessible --enable-performance-insights

查看新 endpoint:

aws rds describe-db-clusters --profile account-b --region ap-southeast-1 --db-cluster-identifier B2 --query 'DBClusters[0].{Status:Status,WriterEndpoint:Endpoint,ReaderEndpoint:ReaderEndpoint,Port:Port,Engine:Engine,Version:EngineVersion,KmsKeyId:KmsKeyId}'

Console 操作路径:

Account B / target Region
    RDS -> Snapshots -> Manual
    select Account B owned DB cluster snapshot
    Actions -> Restore snapshot
    choose Aurora PostgreSQL cluster identifier B2
    choose VPC / subnet group / security groups
    choose cluster and instance parameter groups
    choose instance class or Serverless v2 capacity
    configure backup, logs, monitoring and deletion protection
    restore and wait until writer is available

Serverless v2 使用不同 compute 参数:cluster 配置 ServerlessV2ScalingConfiguration,DB instance class 使用 db.serverless。不要把 provisioned 示例中的 db.r7g.large 原样用于 Serverless v2。

Restore 完成后还要重新处理 master credential/Secrets Manager、IAM database authentication、CloudWatch alarms、Enhanced Monitoring、Performance Insights KMS、Route 53/application endpoint 和 maintenance/backup window。先完成只读、写入、transaction、extension、role/grant 和 sequence 验证,再开放业务流量。

4. 停机逻辑迁移:pg_dump/pg_restore#

Use pg_dump/pg_restore when:

only selected databases/schemas/tables are required
target major version differs but PostgreSQL dump compatibility is supported
schema needs intentional redesign
snapshot sharing/KMS constraints are unacceptable
database size fits the available downtime

Recommended directory format for parallel dump/restore:

pg_dump --host SOURCE-WRITER-ENDPOINT --port 5432 --username migration_user --dbname appdb --format directory --jobs 8 --no-owner --no-privileges --file appdb.dump

Restore to Account B:

pg_restore --host TARGET-WRITER-ENDPOINT --port 5432 --username migration_user --dbname appdb --jobs 8 --no-owner --no-privileges --exit-on-error appdb.dump

For a remote transfer, the dump directory can be uploaded to a private S3 bucket, copied across accounts/Regions, then downloaded near the target. S3 is only the transport; pg_restore still performs the database import.

Migration notes:

roles and grants:
    --no-owner/--no-privileges avoids source role failures
    recreate approved target roles and grants separately

extensions:
    install supported target extension versions before restore when required

large database:
    use directory format + parallel jobs
    measure dump, transfer, restore, index build, analyze duration

consistency:
    pg_dump uses a consistent snapshot
    stop writes before dump if there is no CDC to catch later changes

statistics:
    run ANALYZE after restore before production traffic

5. 低停机迁移:AWS DMS Full Load + CDC#

DMS can copy existing rows and then continue reading PostgreSQL WAL changes until cutover:

Account A Aurora PostgreSQL A1
    -> DMS full load
    -> Account B Aurora PostgreSQL B2

Account A WAL changes
    -> DMS CDC
    -> INSERT / UPDATE / DELETE on B2

Recommended sequence:

  1. Build Account B Aurora PostgreSQL target with compatible schema.
  2. Establish private network connectivity from DMS to both clusters.
  3. Enable source logical replication and required replication capacity.
  4. Create least-privilege source/target database users.
  5. Migrate schema objects separately.
  6. Start DMS task with full-load-and-cdc.
  7. Validate full-load table statistics and CDC errors.
  8. Stop DDL changes during migration.
  9. Enter a short write maintenance window.
  10. Wait for CDC latency to reach zero and verify row/hash/sequence state.
  11. Stop the task at a controlled position and switch the application.

Source logical replication#

In the Aurora PostgreSQL cluster parameter group:

rds.logical_replication = 1
max_replication_slots = enough for DMS tasks plus safety margin
max_wal_senders = enough for active logical/physical senders

rds.logical_replication is a static parameter and normally requires a writer restart. Plan and verify the reboot before the migration window.

Example source user baseline; adjust schemas and tables instead of granting all application data blindly:

CREATE USER dms_user WITH LOGIN PASSWORD 'USE-SECRETS-MANAGER';
GRANT rds_replication TO dms_user;
GRANT CONNECT ON DATABASE appdb TO dms_user;
GRANT USAGE ON SCHEMA public TO dms_user;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO dms_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT ON TABLES TO dms_user;

Tables should have a primary key. For tables without a suitable key, PostgreSQL logical decoding may not have enough identity information for correct UPDATE/DELETE replication. Evaluate:

ALTER TABLE public.example REPLICA IDENTITY FULL;

REPLICA IDENTITY FULL increases WAL volume and CDC cost; adding a stable primary key is usually better.

Network#

DMS must reach both database endpoints on TCP 5432. Cross-account/Region choices include:

Transit Gateway inter-Region/account attachments
VPC peering, including cross-account/cross-Region where supported
site-to-site VPN
controlled public endpoints as a last resort, with TLS and narrow security groups

Verify route tables, security groups, NACLs, DNS resolution and TLS certificates. IAM permission to create a DMS endpoint does not provide database network connectivity.

Schema objects DMS does not replace#

Prepare the target schema with pg_dump --schema-only, AWS SCT where applicable, or reviewed migrations. Do not assume DMS fully migrates:

database roles and grants
extensions
functions and procedures
views and materialized views
triggers
all indexes and constraints
sequence current values
DDL changes during CDC
large object behavior outside the selected DMS LOB mode

When target schema is pre-created, configure the DMS table preparation mode intentionally, commonly DO_NOTHING, so DMS does not drop reviewed objects.

Sequences#

PostgreSQL logical replication and ordinary DMS CDC do not treat sequence advancement like table row DML. Before cutover, set each target sequence to at least the source value while source writes are stopped:

SELECT sequence_schema, sequence_name
FROM information_schema.sequences
ORDER BY sequence_schema, sequence_name;

Generate and review setval statements for the actual schema. A stale target sequence can create duplicate key errors immediately after cutover even when all table rows were copied correctly.

DMS monitoring#

Monitor:

DMS task status and table statistics
FullLoadThroughputRowsSource / FullLoadThroughputRowsTarget
CDCIncomingChanges
CDCLatencySource
CDCLatencyTarget
task logs and table validation failures
source replication slot retained WAL
Aurora FreeLocalStorage / transaction log disk usage signals
target CPU, connections, locks, IOPS and write latency

If the DMS task stops while its replication slot remains, source WAL can continue accumulating and exhaust storage. Alert on CDC lag and retained WAL; define how to drop abandoned slots safely.

6. Native PostgreSQL Logical Replication#

Native logical replication can perform initial table copy and then stream row changes:

source publication in Account A
    -> network/TLS
    -> target subscription in Account B

Source example:

CREATE PUBLICATION account_b_migration
FOR TABLE
  public.orders,
  public.order_items;

Target example after schema creation:

CREATE SUBSCRIPTION account_a_source
CONNECTION 'host=SOURCE-ENDPOINT port=5432 dbname=appdb user=replication_user sslmode=verify-full'
PUBLICATION account_b_migration
WITH (
  copy_data = true,
  create_slot = true,
  enabled = true
);

Do not place plaintext production passwords in committed SQL or shell history. Use a controlled execution path and rotate migration credentials after cutover.

Native logical replication still requires:

target tables created first
compatible column definitions
source logical replication enabled
network connectivity and TLS
primary key / replica identity for update/delete
manual DDL and sequence handling
subscription/slot monitoring
conflict policy when target is writable

For a one-time migration, keep B2 application-read-only until cutover. Bidirectional logical replication requires explicit origin, conflict and loop prevention design; it is not a default extension of this plan.

7. S3 Export Options Are Not Equivalent#

Three S3 workflows have different meanings:

Workflow Output Can directly restore Aurora?
RDS/Aurora snapshot export to S3 columnar analytics files, commonly Parquet No
aws_s3.query_export_to_s3 query/table result files No; custom table import required
pg_dump files stored in S3 PostgreSQL logical dump archive Yes, through pg_restore, not directly by Aurora

Use snapshot export to S3 for Athena/analytics, not as the primary cross-account Aurora restore mechanism. Use a DB cluster snapshot for physical managed restore, or pg_dump/DMS/logical replication for logical migration.

Console Restore From S3#

RDS Console 中看到 Restore from S3 不表示 Aurora PostgreSQL 可以从 snapshot export files 恢复。这个入口主要面向特定 engine/backup format,例如使用 Percona XtraBackup 文件迁移到 Aurora MySQL。

Aurora MySQL Restore from S3:
    supports specific MySQL backup formats such as XtraBackup

Aurora PostgreSQL snapshot export to S3:
    produces analytics files
    cannot be passed to Restore from S3

Aurora PostgreSQL aws_s3 extension:
    can import/export selected table/query files
    does not restore a complete cluster

PostgreSQL pg_dump stored in S3:
    download near the target
    restore with pg_restore
    not restored by the RDS Restore from S3 wizard

因此 Aurora PostgreSQL 整 cluster 迁移使用 DB cluster snapshot restore;只在逻辑迁移时使用 pg_dump/pg_restore,S3 可以作为 dump 文件的传输位置。

8. Validation And Cutover#

Validation should cover more than row count:

database structure:
    database/schema/table/partition count
    indexes and constraints valid
    extensions, functions, views and triggers present

data:
    row counts for every critical table
    deterministic checksums or sampled key comparisons
    min/max timestamps and business totals
    large objects and NULL/encoding/timezone cases

runtime:
    representative read/write transactions
    connection pool and TLS behavior
    query plans after ANALYZE
    target CPU/IOPS/locks/latency

security:
    roles/grants/RLS
    KMS and Secrets Manager
    security groups and IAM database authentication
    audit/log exports

Low-downtime cutover:

1. announce maintenance window
2. stop all source writers and background jobs
3. keep reads only if the application tolerates them
4. wait for DMS/logical replication lag to reach zero
5. verify final row/hash/sequence state
6. stop replication at a recorded position
7. switch secrets, endpoint or Route 53
8. run target smoke tests
9. resume writes only on B2
10. monitor errors, latency and replication remnants

Rollback must be defined before cutover. Once B2 accepts writes, A1 becomes stale. Switching the endpoint back without reverse migration loses target-side changes.

放行门禁与停止线#

迁移前填写 执行边界,固定源/目标版本、实际停机预算、备份恢复证据与业务对账查询。快照、逻辑导出、DMS 和原生复制是不同路径,不跨路径套用恢复步骤。

DMS(Database Migration Service,数据库迁移服务)路径增加以下只读检查;使用迁移任务所在账号/区域:

export DMS_PROFILE='REPLACE_MIGRATION_PROFILE'
export DMS_REGION='REPLACE_MIGRATION_REGION'
export TASK_ARN='REPLACE_DMS_TASK_ARN'
aws dms describe-replication-tasks --profile "$DMS_PROFILE" --region "$DMS_REGION" --filters "Name=replication-task-arn,Values=$TASK_ARN" --query 'ReplicationTasks[].{Status:Status,Failure:LastFailureMessage,Stats:ReplicationTaskStats,Checkpoint:RecoveryCheckpoint}'
aws dms describe-table-statistics --profile "$DMS_PROFILE" --region "$DMS_REGION" --replication-task-arn "$TASK_ARN" --query 'TableStatistics[].{Schema:SchemaName,Table:TableName,State:TableState,Validation:ValidationState,Pending:ValidationPendingRecords,Failed:ValidationFailedRecords,Suspended:ValidationSuspendedRecords}'

放行要求:纳入范围的表全部完成全量,无错误/挂起;已启用且支持校验的表在停写收敛后无待校验/失败项。不支持校验的表另有确定性比对证据;缺字段或未启用校验不等于通过。最终停写水位、关键表摘要、金额/状态对账、序列和权限全部通过后才能停复制与切入口。延迟为零只是辅助信号。DMS 校验限制与状态。

阶段/异常 停止及恢复动作
源仍写入、任务失败、校验不一致、日志保留逼近容量上限 不切流;保留任务与复制位点,评估源存储风险,不能直接删除 slot 释放空间后继续原任务
停机预算将耗尽,目标尚未写入 隔离目标,核对源健康后恢复源业务;另排迁移窗口,重新取得最终水位
目标烟雾测试或正式业务已写入 保持源写入隔离;冻结目标后对账,按预演的反向迁移/补偿方案恢复;测试写入也属于新增状态
目标健康但业务结果或权限异常 停在验收阶段,修复权限/配置或恢复方案;不能以 cluster available 作为成功

原生逻辑复制另外验证发布/订阅范围、每表同步状态及停写后的应用进度,不套用 DMS 状态。结束前保留源和复制恢复所需状态,确认回退期结束后再清理任务、slot、快照共享与临时身份。

9. Security And Cost#

network:
    prefer private connectivity
    restrict TCP 5432 to migration sources
    enforce PostgreSQL TLS

credentials:
    store in Secrets Manager
    separate snapshot/DMS/database roles
    rotate temporary migration users

KMS:
    cross-account encrypted snapshot requires customer managed keys
    key policy and IAM identity policy must both allow required operations
    AWS managed aws/rds key cannot be edited for cross-account sharing

cost:
    cross-Region snapshot/data transfer
    duplicate Aurora cluster runtime
    DMS replication capacity/serverless usage
    WAL retention and source storage growth
    S3 dump/snapshot export storage
    KMS requests

10. Checklist#

[ ] migration mode selected: snapshot / pg_dump / DMS / logical replication
[ ] same-account Global Database was not mistaken for cross-account replication
[ ] source/target engine versions and extensions are compatible
[ ] source size and migration duration were measured in rehearsal
[ ] network/TLS connectivity reaches both clusters
[ ] customer managed KMS policies support snapshot or S3 workflow
[ ] schema, roles, grants, functions, triggers, views and extensions are planned
[ ] tables without PK have an explicit replica identity decision
[ ] LOB mode and unsupported data types are tested
[ ] sequence values are synchronized before cutover
[ ] DMS/logical replication lag and retained WAL are monitored
[ ] row counts, checksums and application smoke tests pass
[ ] B2 is the only writer after cutover
[ ] rollback after B2 writes has a reverse-migration plan
[ ] old replication slots/tasks and temporary credentials are removed safely

搜索文档

输入关键词,搜索所有文档。

↑ ↓ 选择 · Enter 打开 · Esc 关闭