我想使用 Amazon DynamoDB 的时间点故障恢复功能,但我不知道如何开启这个功能。
简短描述
要为您的 DynamoDB 实例开启时间点故障恢复 (PITR),请使用以下方法之一:
- DynamoDB 控制台
- AWS 命令行界面 (AWS CLI)
- AWS CloudFormation
- DynamoDB API
**注意:**DynamoDB 会根据每个 DynamoDB 表的大小(包括表数据和本地二级索引)对 PITR 收费。为了确定您的备份费用,DynamoDB 会持续监控开启了 PITR 的表的大小。系统会按照 PITR 的使用量计费,直到您关闭每个表的 PITR。
解决方法
DynamoDB 控制台
完成以下步骤:
- 打开 DynamoDB 控制台。
- 在导航窗格中,选择 Tables(表),然后选择您的表。
- 在 Backups(备份)下,对于 Point-in-time recovery (PITR)(时间点故障恢复 (PITR))选项中,选择 Edit(编辑)。
- 选择 Turn on point-in-time recovery(开启时间点故障恢复),然后选择 Save changes(保存更改)。
AWS CLI
注意:如果在运行 AWS CLI 命令时收到错误,请参阅排查 AWS CLI 错误。此外,请确保您使用的是最新版本的 AWS CLI。
在开启 point-in-time-recovery-specification 设置的情况下,运行 update-continuous-backups 命令:
aws dynamodb update-continuous-backups \
--table-name <table-name>\
--point-in-time-recovery-specification PointInTimeRecoveryEnabled=true
CloudFormation
使用开启了 PointInTimeRecoverySpecification 属性的 AWS::DynamoDB::Table 资源:
Resources:
iotCatalog:
Type: AWS::DynamoDB::Table
Properties:
...
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
DynamoDB API
在开启 PointInTimeRecoverySpecification 参数的情况下,运行 UpdateContinuousBackups API 操作。
请求语法示例:
{
"PointInTimeRecoverySpecification": {
"PointInTimeRecoveryEnabled": boolean
},
"TableName": "string"
}
响应语法示例:
{
"ContinuousBackupsDescription": {
"ContinuousBackupsStatus": "string",
"PointInTimeRecoveryDescription": {
"EarliestRestorableDateTime": number,
"LatestRestorableDateTime": number,
"PointInTimeRecoveryStatus": "string"
}
}
}
相关信息
使用时间点故障恢复来还原表