使用AWS DMS的task设置“include-tables”参数来指定需要迁移的表格,并为不同模式的表格分别创建task。示例代码如下:
创建一个迁移源为RDS实例的task,迁移RDS中默认模式(public)下的“orders”表格:
{
"ResourceArn": "arn:aws:rds:us-west-2:123456789012:db:test-source",
"MigrationType": "full-load",
"FullLoadSettings": {
"TargetTablePrepMode": "TRUNCATE_BEFORE_LOAD",
"CreatePkForRethinkDb": true
},
"TableMappings": "{\"rules\":[{\"rule-type\":\"selection\",\"rule-id\":\"1\",\"rule-name\":\"1\",\"object-locator\":{\"schema-name\":\"public\",\"table-name\":\"orders\"},\"rule-action\":\"include\",\"filters\":[]}]}",
"TargetEndpointArn": "arn:aws:dms:us-west-2:123456789012:endpoint:test-target"
}
在上述代码中,我们使用了“TableMappings”属性来指定要迁移的表格,将“schema-name”设置为“public”,表格名称设置为“orders”。
在创建另一个task时,将上述代码中“schema-name”修改为要迁移的另一个模式名称即可。如:
{
"ResourceArn": "arn:aws:rds:us-west-2:123456789012:db:test-source",
"MigrationType": "full-load",
"FullLoadSettings": {
"TargetTablePrepMode": "TRUNCATE_BEFORE_LOAD",
"CreatePkForRethinkDb": true
},
"TableMappings": "{\"rules\":[{\"rule-type\":\"selection\",\"rule-id\":\"1\",\"rule-name\":\"1\",\"object-locator\":{\"schema-name\":\"sales\",\"table-name\":\"orders\"},\"rule-action\":\"include\",\"filters\":[]}]}",
"TargetEndpointArn": "arn:aws:dms:us-west-2:123456789012:endpoint:test-target"
}