复制任务设置 JSON 上的 Boto3 DMS 'modify_replication_task' 错误
Posted
技术标签:
【中文标题】复制任务设置 JSON 上的 Boto3 DMS \'modify_replication_task\' 错误【英文标题】:Boto3 DMS 'modify_replication_task' error on replication task settings JSON复制任务设置 JSON 上的 Boto3 DMS 'modify_replication_task' 错误 【发布时间】:2019-10-14 13:47:42 【问题描述】:我正在使用 boto3 创建 DMS 复制任务。我正在使用以下replication_task_settings.json
来创建复制任务:
"TargetMetadata":
"TargetSchema": "",
"SupportLobs": true,
"FullLobMode": false,
"LobChunkSize": 0,
"LimitedSizeLobMode": true,
"LobMaxSize": 256,
"InlineLobMaxSize": 0,
"LoadMaxFileSize": 0,
"ParallelLoadThreads": 0,
"ParallelLoadBufferSize": 0,
"BatchApplyEnabled": false,
"TaskRecoveryTableEnabled": false
,
"FullLoadSettings":
"TargetTablePrepMode": "TRUNCATE_BEFORE_LOAD",
"CreatePkAfterFullLoad": false,
"StopTaskCachedChangesApplied": false,
"StopTaskCachedChangesNotApplied": false,
"MaxFullLoadSubTasks": 8,
"TransactionConsistencyTimeout": 1000,
"CommitRate": 10000
,
"Logging":
"EnableLogging": true,
"LogComponents": [
"Id": "SOURCE_UNLOAD",
"Severity": "LOGGER_SEVERITY_DEFAULT"
,
"Id": "TARGET_LOAD",
"Severity": "LOGGER_SEVERITY_DEFAULT"
,
"Id": "SOURCE_CAPTURE",
"Severity": "LOGGER_SEVERITY_DEFAULT"
,
"Id": "TARGET_APPLY",
"Severity": "LOGGER_SEVERITY_DEFAULT"
,
"Id": "TASK_MANAGER",
"Severity": "LOGGER_SEVERITY_DEFAULT"
],
,
"ControlTablesSettings":
"ControlSchema": "control",
"HistoryTimeslotInMinutes": 5,
"HistoryTableEnabled": true,
"SuspendedTablesTableEnabled": true,
"StatusTableEnabled": true
,
"StreamBufferSettings":
"StreamBufferCount": 3,
"StreamBufferSizeInMB": 8,
"CtrlStreamBufferSizeInMB": 5
,
"ChangeProcessingDdlHandlingPolicy":
"HandleSourceTableDropped": false,
"HandleSourceTableTruncated": true,
"HandleSourceTableAltered": false
,
"ErrorBehavior":
"DataErrorPolicy": "LOG_ERROR",
"DataTruncationErrorPolicy": "LOG_ERROR",
"DataErrorEscalationPolicy": "SUSPEND_TABLE",
"DataErrorEscalationCount": 0,
"TableErrorPolicy": "SUSPEND_TABLE",
"TableErrorEscalationPolicy": "STOP_TASK",
"TableErrorEscalationCount": 0,
"RecoverableErrorCount": -1,
"RecoverableErrorInterval": 5,
"RecoverableErrorThrottling": true,
"RecoverableErrorThrottlingMax": 1800,
"ApplyErrorDeletePolicy": "IGNORE_RECORD",
"ApplyErrorInsertPolicy": "LOG_ERROR",
"ApplyErrorUpdatePolicy": "LOG_ERROR",
"ApplyErrorEscalationPolicy": "LOG_ERROR",
"ApplyErrorEscalationCount": 0,
"ApplyErrorFailOnTruncationDdl": false,
"FullLoadIgnoreConflicts": true,
"FailOnTransactionConsistencyBreached": false,
"FailOnNoTablesCaptured": false
,
"ChangeProcessingTuning":
"BatchApplyPreserveTransaction": true,
"BatchApplyTimeoutMin": 1,
"BatchApplyTimeoutMax": 30,
"BatchApplyMemoryLimit": 500,
"BatchSplitSize": 0,
"MinTransactionSize": 1000,
"CommitTimeout": 1,
"MemoryLimitTotal": 1024,
"MemoryKeepTime": 60,
"StatementCacheSize": 50
,
"ValidationSettings":
"EnableValidation": true,
"ValidationMode": "ROW_LEVEL",
"ThreadCount": 5,
"PartitionSize": 10000,
"FailureMaxCount": 10000,
"RecordFailureDelayInMinutes": 5,
"RecordSuspendDelayInMinutes": 30,
"MaxKeyColumnSize": 8096,
"TableFailureMaxCount": 1000,
"ValidationOnly": false,
"HandleCollationDiff": false,
"RecordFailureDelayLimitInMinutes": 0
调用dms_client.create_replication_task
时,上面的 JSON 可以正常工作。但是,修改复制任务时不起作用。
当使用上面提到的replication_task_settings.json
调用dms_client.modify_replication_task
时,我收到以下错误:
botocore.exceptions.ClientError: An error occurred (InvalidParameterValueException) when calling the ModifyReplicationTask operation: Invalid task settings JSON
我不知道为什么会这样,任何帮助将不胜感激!
我尝试删除一些已经默认的设置。我尝试寻找格式错误的 JSON,但没有什么明显的。
我希望replication_task_settings,json
可以用于创建和修改 DMS 复制任务。
【问题讨论】:
【参考方案1】:tableMappings 的 modify_replication_task() 的 boto3 文档建议 -- 在使用 CLI 或 boto3 时,提供包含表映射的 JSON 文件的路径。在路径前加上 file:// 。例如, --table-mappings file://mappingfile.json 。使用 DMS API 时,提供 JSON 作为参数值。
是的,你完全正确。 提供 JSON 文件作为参数在 CLI 中有效,但在 boto3 中无效。在 boto3 中,它会引发错误“Invalid TableMappings / Invalid JSON error”。
尝试以下方法使其工作:
import boto3
dms_client = boto3.client('dms')
table_mapping =
"rules":[
"rule-type":"selection",
"rule-id":str(idx),
"rule-name":str(idx),
"object-locator":
"schema-name":schema_name,
"table-name":table_name
,
"rule-action":"include"
]
dms_client.modify_replication_task(
ReplicationTaskArn=repl_task_arn,
TableMappings=json.dumps(table_mapping)
)
【讨论】:
【参考方案2】:我在尝试使用 CLI 修改复制任务时遇到了类似的问题:
aws --profile non-prod dms modify-replication-task --replication-task-arn arn:aws:dms:ap-southeast-3:567384657322:task:ABC --replication-task-settings file:/json_task --region ap-southeast-3
这是错误:
调用时发生错误(InvalidParameterValueException) ModifyReplicationTask 操作:无效的任务设置 JSON
以下命令有效:
aws --profile non-prod dms modify-replication-task --replication-task-arn arn:aws:dms:ap-southeast-3:567384657322:task:ABC --replication-task-settings file://json_task --region ap-southeast-3
更改是在JSON文件名前使用两个“//”来修改任务。
【讨论】:
以上是关于复制任务设置 JSON 上的 Boto3 DMS 'modify_replication_task' 错误的主要内容,如果未能解决你的问题,请参考以下文章
AWS DMS:复制任务已停止。停止原因 FULL_LOAD_ONLY_FINISHED