本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
还原到某个时间点
使用 Amazon Web Services Management Console或 Amazon Command Line Interface (Amazon CLI) 可将集群还原到该集群的备份保留期内的任何时间点。
您无法将 3.6 集群的时间点还原到 4.0 集群,但可以从一个群集版本迁移到另一个群集版本。有关更多信息,请转至 迁移到 Amazon DocumentDB。
在将集群还原至某个时间点时,请牢记以下几点。
-
创建新集群时将使用与源集群相同的配置,区别在于创建新集群时将使用默认参数组。要将新集群的参数组设置为源集群的参数组,请在新集群可用 后对其进行修改。有关修改集群的更多信息,请参阅修改 Amazon DocumentDB 集群。
使用 Amazon Web Services Management Console还原到时间点
可以使用 Amazon Web Services Management Console完成以下操作,以将集群还原到该集群的备份保留期内的某个时间点。
登录到Amazon Web Services Management Console,然后在以下位置打开 Amazon DocumentDB 控制台https://console.aws.amazon.com/docdb
. -
在导航窗格中,选择 Clusters。在集群列表中,选择要还原的集群左侧的按钮。
提示 如果您在屏幕左侧没有看到导航窗格,请在页面左上角选择菜单图标 (
)。
-
在 Actions (操作) 菜单上,选择 Restore to point in time (还原到时间点)。
-
完成 Restore time (恢复时间) 部分,用于指定将还原到的日期和时间。
-
还原日期— 选择或输入的日期介于最早还原时间和最晚还原时间.
-
恢复时间— 选择或输入介于最早还原时间和最晚还原时间.
-
-
填写 Configuration (配置) 部分。
-
集群标识符— 接受默认标识符,或者输入您喜欢的标识符。
集群命名约束:
-
长度为 [1-63] 个字母、数字或连字符。
-
第一个字符必须是字母。
-
不能以连字符结束或包含两个连续连字符。
-
对于每个 Amazon DocumentDB 的所有集群(在、和 Neptune)必须是唯一的。Amazon Web Services 账户每区域数。
-
-
实例类— 从下拉列表中,选择要用于集群实例的实例类。
-
实例的数量— 从下拉列表中,选择还原集群时您希望创建的实例的数量。
-
-
可选。要配置网络设置、集群选项和启用日志导出,请选择 Show advanced settings (显示高级设置),然后完成以下各部分。否则,请继续下一步。
-
Network settings (网络设置)
-
Virtual Private Cloud (VPC)— 从下拉列表中,选择要用于此集群的 VPC。
-
子网组— 从下拉列表中,为此集群选择子网组。
-
VPC 安全组— 从下拉列表中,为此集群选择 VPC 安全组。
-
-
Cluster options (集群选项)
-
端口— 接受默认端口 (27017),或者使用向上或向下箭头来设置此集群进行通信的端口。
-
-
日志导出
-
审核日志— 选择此选项可启用将审计日志导出到 Amazon CloudWatch Logs 的功能。如果您选择此选项,则必须在集群的自定义参数组中启用
audit_logs
。有关更多信息,请参阅审核 Amazon DocumentDB 事件。 -
Profiler 日志— 选择此选项可启用将操作分析器日志导出到 Amazon CloudWatch Logs 的功能。如果您选择此选项,还必须在集群的自定义参数组中修改以下参数:
-
profiler
— 设置为enabled
. -
profiler_threshold_ms
— 设置为值[0-INT_MAX]
以设置分析操作的阈值。 -
profiler_sampling_rate
— 设置为值[0.0-1.0]
以设置要分析的缓慢操作的百分比。
有关更多信息,请参阅分析 Amazon DocumentDB 操作。
-
-
Profiler 日志— 将分析器日志导出到 Amazon CloudWatch
-
IAM 角色— 从下拉列表中,选择RDS 服务相关角色.
-
-
标签
-
添加标签— 在密钥框中,输入集群标签的名称。在 Value (值) 框中,可以选择输入标签值。标签用于Amazon Identity and Access Management(IAM) 策略来管理对 Amazon DocumentDB 资源的访问并控制可将什么操作应用于资源。
-
-
删除保护
-
启用删除保护— 防止意外删除集群。启用该选项后,您将无法删除集群。
-
-
-
要还原集群,请选择 Create cluster (创建集群)。或者,您可以选择 Cancel (取消) 以取消操作。
使用 Amazon CLI 还原到时间点
要使用快照的备份保留期将集群还原到某个时间点,请使用带有以下参数的 restore-db-cluster-to-point-in-time
操作。
-
--db-cluster-identifier
– 必需。要创建的新集群的名称。在执行该操作之前,不能存在此集群。参数值必须满足以下约束。集群命名约束:
-
长度为 [1-63] 个字母、数字或连字符。
-
第一个字符必须是字母。
-
不能以连字符结束或包含两个连续连字符。
-
对于每个 Amazon DocumentDB 的所有集群(在、和 Neptune)必须是唯一的。Amazon Web Services 账户每区域数。
-
-
--restore-to-time
— 要将集群还原到的 UTC 日期和时间。例如2018-06-07T23:45:00Z
。时间约束:
-
必须在集群的最新可还原时间之前。
-
如果未提供
--use-latest-restorable-time
参数,则必须指定。 -
如果
--use-latest-restorable-time
参数为true
,则无法指定。 -
如果
--restore-type
参数值为copy-on-write
,则无法指定。
-
-
--source-db-cluster-identifier
— 要从中还原的源集群的名称。该集群必须存在且可用。 -
--use-latest-restorable-time
要么--no-use-latest-restorable-time
— 是否还原至最近的可还原备份时间。如果未提供--restore-to-time
参数,则无法指定。
Amazon CLI 操作 restore-db-cluster-to-point-in-time
仅还原集群,而不还原该集群的实例。您必须调用 create-db-instance
操作为还原的集群创建实例,并在 --db-cluster-identifier
中指定还原的集群的标识符。仅当完成 restore-db-cluster-to-point-in-time
操作并且还原的集群可用 后,您才能创建实例。
以下示例从快照 sample-cluster-snapshot
创建到最近可还原时间的 sample-cluster-restored
。
对于 Linux、macOS 或 Unix:
aws docdb restore-db-cluster-to-point-in-time \ --db-cluster-identifier sample-cluster-restored \ --source-db-cluster-identifier sample-cluster-snapshot \ --use-latest-restorable-time
对于 Windows:
aws docdb restore-db-cluster-to-point-in-time ^ --db-cluster-identifier sample-cluster-restored ^ --source-db-cluster-identifier sample-cluster-snapshot ^ --use-latest-restorable-time
以下示例从快照 sample-cluster-snapshot
创建到 2018 年 12 月 11 日 03:15 (UTC)(在 sample-cluster
的备份保留期内)的 sample-cluster-restored
。
对于 Linux、macOS 或 Unix:
aws docdb restore-db-cluster-to-point-in-time \ --db-cluster-identifier sample-cluster-restore \ --source-db-cluster-identifier sample-cluster \ --restore-to-time 2020-05-12T03:15:00Z
对于 Windows:
aws docdb restore-db-cluster-to-point-in-time ^ --db-cluster-identifier sample-cluster-restore ^ --source-db-cluster-identifier sample-cluster ^ --restore-to-time 2020-05-12T03:15:00Z
此操作的输出将类似于下文。
{
"DBCluster": {
"AvailabilityZones": [
"us-east-1c",
"us-west-2b",
"us-west-2a"
],
"BackupRetentionPeriod": 1,
"DBClusterIdentifier": "sample-cluster-restored",
"DBClusterParameterGroup": "sample-parameter-group",
"DBSubnetGroup": "default",
"Status": "creating",
"Endpoint": "sample-cluster-restored.node.us-east-1.docdb.amazonaws.com",
"ReaderEndpoint": "sample-cluster-restored.node.us-east-1.docdb.amazonaws.com",
"MultiAZ": false,
"Engine": "docdb",
"EngineVersion": "4.0.0",
"Port": 27017,
"MasterUsername": "master-user",
"PreferredBackupWindow": "02:00-02:30",
"PreferredMaintenanceWindow": "tue:09:50-tue:10:20",
"DBClusterMembers": [],
"VpcSecurityGroups": [
{
"VpcSecurityGroupId": "sg-abc0123",
"Status": "active"
}
],
"HostedZoneId": "ABCDEFGHIJKLM",
"StorageEncrypted": true,
"KmsKeyId": "arn:aws:kms:us-east-1:<accountID^>:key/sample-key",
"DbClusterResourceId": "cluster-ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"DBClusterArn": "arn:aws:rds:us-east-1:<accountID>:cluster:sample-cluster-restored",
"AssociatedRoles": [],
"ClusterCreateTime": "2020-04-24T20:14:36.713Z",
"DeletionProtection": false
}
}