还原到某个时间点 - Amazon DocumentDB
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

还原到某个时间点

您可以使用 Amazon Web Services Management Console 或 Amazon Command Line Interface (Amazon CLI) 将集群还原到集群备份保留期内的任何时间点。

注意

您无法将 3.6 集群 point-in-time 还原到 4.0 集群,但可以从一个集群版本迁移到另一个集群版本。有关更多信息,请转至 迁移到 Amazon DocumentDB

在将集群还原至某个时间点时,请牢记以下几点。

  • 创建新集群时将使用与源集群相同的配置,区别在于创建新集群时将使用默认参数组。要将新集群的参数组设置为源集群的参数组,请在新集群可用 后对其进行修改。有关修改集群的更多信息,请参阅修改亚马逊文档数据库集群

Using the Amazon Web Services Management Console

您可以使用完成以下操作,将群集还原到其备份保留期 point-in-time 内 Amazon Web Services Management Console。

  1. 登录并打开亚马逊 DocumentDB 控制台,网址为 https://console.aws.amazon.com/docdb。 Amazon Web Services Management Console

  2. 在导航窗格中,选择集群。在集群列表中,选择要还原的集群左侧的按钮。

    提示

    如果您在屏幕左侧没有看到导航窗格,请在页面左上角选择菜单图标 ()。

  3. Actions (操作) 菜单上,选择 Restore to point in time (还原到时间点)

  4. 完成 Restore time (恢复时间) 部分,用于指定将还原到的日期和时间。

    1. 还原日期 — 选择或输入介于最早还原时间最新还原时间之间的日期。

    2. 还原时间 — 选择或输入介于最早还原时间最新还原时间之间的小时、分钟和秒。

  5. 填写 Configuration (配置) 部分。

    1. 集群标识符 — 接受默认标识符,或者输入您喜欢的标识符。

      集群命名约束:

      • 长度为 [1-63] 个字母、数字或连字符。

      • 第一个字符必须是字母。

      • 不能以连字符结束或包含两个连续连字符。

      • 每个区域的 Amazon RDS、Neptune 和 Amazon DocumentDB 中的所有集群都必须是唯一 Amazon Web Services 账户的。

    2. 实例类 — 从下拉列表中,选择要用于集群实例的实例类。

    3. 实例数 — 从下拉列表中,选择还原此集群时您希望创建的实例的数量。

  6. 对于集群存储配置,请选择存储选项。

    注意

    亚马逊 DocumentDB I/O 优化的存储配置仅适用于亚马逊 DocumentDB 5.0 引擎版本。

  7. 可选。要配置网络设置、集群选项和启用日志导出,请选择 Show advanced settings (显示高级设置),然后完成以下各部分。否则,请继续下一步。

    • Network settings (网络设置)

      1. 虚拟私有云(VPC)— 从下拉列表中,选择要用于此集群的 VPC。

      2. 子网组 — 从下拉列表中,为此集群选择子网组。

      3. VPC 安全组 — 从下拉列表中,为此集群选择 VPC 安全组。

       

    • Cluster options (集群选项)

      1. 端口 — 接受默认端口 (27017),或者使用向上或向下箭头来设置与此集群进行通信的端口。

       

    • 日志导出

      1. 审核日志-选择此选项可启用将审核日志导出到 Amazon CloudWatch Logs。如果您选择此选项,则必须在集群的自定义参数组中启用 audit_logs。有关更多信息,请参阅 审核 Amazon DocumentDB 活动

      2. Profiler 日志-选择此选项可启用将操作分析器日志导出到 Ama CloudWatch zon Logs。如果您选择此选项,还必须在集群的自定义参数组中修改以下参数:

        • profiler — 设置为 enabled

        • profiler_threshold_ms — 设置为值 [0-INT_MAX],以设置分析操作的阈值。

        • profiler_sampling_rate — 设置为值 [0.0-1.0],以设置要分析的缓慢操作的百分比。

        有关更多信息,请参阅 分析 Amazon DocumentDB 操作

      3. Profiler 日志 — 将分析器日志导出到 Amazon CloudWatch

      4. IAM 角色 — 从下拉列表中,选择 RDS 服务相关角色

    • 标签

      1. 添加标签 — 在密钥框中,输入集群标签的名称。在 Value (值) 框中,可以选择输入标签值。标签与 Amazon Identity and Access Management (IAM) 策略结合使用,以管理对 Amazon DocumentDB 资源的访问并控制可将什么操作应用于资源。

    • 删除保护

      1. 启用删除保护 — 防止集群被意外删除。启用该选项后,您将无法删除集群。

  8. 要还原集群,请选择 Create cluster (创建集群)。或者,您可以选择 Cancel (取消) 以取消操作。

Using the Amazon CLI

要使用快照的备份保留期将集群还原到某个时间点,请使用带有以下参数的 restore-db-cluster-to-point-in-time 操作。

  • --db-cluster-identifier — 必填项。要创建的新集群的名称。在执行该操作之前,不能存在此集群。参数值必须满足以下约束。

    集群命名约束:

    • 长度为 [1-63] 个字母、数字或连字符。

    • 第一个字符必须是字母。

    • 不能以连字符结束或包含两个连续连字符。

    • 每个区域的 Amazon RDS、Neptune 和 Amazon DocumentDB 中的所有集群都必须是唯一 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 参数,则无法指定。

  • --storage-type standard | iopt1 – 可选。默认值:standard

该 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 } }