

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

# 使用 DR Orchestrator Framework 自动执行跨区域故障转移和故障恢复
<a name="automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework"></a>

*Jitendra Kumar、Pavithra Balasubramanian 和 Oliver Francis，Amazon Web Services*

## Summary
<a name="automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework-summary"></a>

此模式描述了如何使用 [DR Orchestrator Framework](https://docs.aws.amazon.com/prescriptive-guidance/latest/automate-dr-solution-relational-database/dr-orchestrator-framework-overview.html) 来编排和自动执行容易出错的手动步骤，以便跨 Amazon Web Services（AWS）区域执行灾难恢复。该模式涵盖了以下数据库：
+ Amazon Relational Database Service（Amazon RDS）for MySQL、Amazon RDS for PostgreSQL 或 Amazon RDS for MariaDB
+ Amazon Aurora MySQL 兼容版本或 Amazon Aurora PostgreSQL 兼容版本（使用集中文件）
+ 亚马逊 ElastiCache （Redis OSS）

为了演示 DR Orchestrator Framework 的功能，您需要创建两个数据库实例或集群。主节点在中 AWS 区域 `us-east-1`，次要在中`us-west-2`。要创建这些资源，您可以使用 [aws-cross-region-dr-databases GitHub 存储库`App-Stack`](https://github.com/aws-samples/aws-cross-region-dr-databases)文件夹中的 AWS CloudFormation 模板。

## 先决条件和限制
<a name="automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework-prereqs"></a>

**一般先决条件**
+ 灾难恢复 Orchestrator 框架同时部署在主服务器和辅助设备中 AWS 区域
+ 两个 [Amazon Simple Storage Service](https://aws.amazon.com/s3/) 存储桶
+ 具有两个子网和一个 AWS 安全组的[虚拟私有云 (VPC)](https://aws.amazon.com/vpc/) 

**引擎特定的先决条件**
+ **亚马逊 Aurora** — 必须至少有一个 Aurora 全球数据库在两个数据库中可用 AWS 区域。您可将 `us-east-1` 作为主要区域，也可将 `us-west-2` 用作辅助区域。
+ **亚马逊 ElastiCache （Redis OSS）**— ElastiCache 全球数据存储必须一分为二。 AWS 区域您可将 `use us-east-1` 作为主要区域，也可将 `us-west-2` 用作辅助区域。

**Amazon RDS 限制**
+ DR Orchestrator Framework 在进行故障转移或故障恢复之前不会检查复制滞后。必须手动检查复制滞后。
+ 此解决方案已使用包含一个只读副本的主数据库实例进行了测试。如果要使用多个只读副本，请在生产环境中实施解决方案之前对其进行全面测试。

**Aurora 限制**
+ 功能可用性和支持因每个数据库引擎的特定版本以及 AWS 区域而异。有关跨区域复制的功能和区域可用性的更多信息，请参阅[跨区域只读副本](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RDS_Fea_Regions_DB-eng.Feature.CrossRegionReadReplicas.html)。
+ Aurora 全局数据库对支持的 Aurora 数据库实例类和最大数量有特定的配置要求 AWS 区域。有关更多信息，请参阅 [Amazon Aurora 全局数据库的配置要求](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-global-database-getting-started.html#aurora-global-database.configuration.requirements)。
+ 此解决方案已使用包含一个只读副本的主数据库实例进行了测试。如果要使用多个只读副本，请在生产环境中实施解决方案之前对其进行全面测试。

**ElastiCache 限制**
+ 有关全球数据存储的区域可用性和 ElastiCache 配置要求的信息，请参阅 ElastiCache 文档中的[先决条件和限制](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Redis-Global-Datastores-Getting-Started.html)。

**Amazon RDS ****产品版本**

Amazon RDS 支持以下引擎版本：
+ **MySQL** – Amazon RDS 支持运行以下版本 [MySQL](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html) 的数据库实例：MySQL 8.0 和 MySQL 5.7
+ **PostgreSQL** – 有关 Amazon RDS for PostgreSQL 的可支持版本的信息，请参阅[可用的 PostgreSQL 数据库版本](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.DBVersions)。
+ **MariaDB** – Amazon RDS 支持运行以下版本 [MariaDB](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MariaDB.html) 的数据库实例：
  + MariaDB 10.11
  + MariaDB 10.6
  + MariaDB 10.5

**Aurora 产品版本**
+ Amazon Aurora 全球数据库切换要求使用与 MySQL 5.7 兼容的 Aurora MySQL 兼容版，且需为 2.09.1 或更高版本

  有关更多信息，请参阅 [Amazon Aurora 全局数据库的限制](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-global-database.html#aurora-global-database.limitations)。

**ElastiCache (Redis OSS) 产品版本**

亚马逊 ElastiCache （Redis OSS）支持以下 Redis 版本：
+ Redis 7.1（加强版）
+ Redis 7.0（加强版）
+ Redis 6.2（加强版）
+ Redis 6.0（加强版）
+ Redis 5.0.6（加强版）

有关更多信息，请参阅[支持的 ElastiCache (Redis OSS) 版本](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Redis-Global-Datastores-Getting-Started.html)。

## 架构
<a name="automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework-architecture"></a>

**Amazon RDS**** 架构**

Amazon RDS 架构包括以下资源：
+ 在主区域 (`us-east-1`) 中创建的主要 Amazon RDS 数据库实例，可供客户端 read/write 访问
+ 在辅助区域（`us-west-2`）中创建的 Amazon RDS 只读副本，为客户端提供只读访问权限
+ DR Orchestrator Framework 同时部署在主要和辅助区域中

![单个 AWS 账户中的双区域 RDS 架构示意图。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/8d39561f-924e-4b3e-8175-c5c3cab163bd/images/ad217033-600c-40da-929c-b9f9aecb4c2c.png)


此图显示以下内容：

1. 实例主集群和辅助实例之间的异步复制

1. 客户端在主要区域中的读/写访问权限

1. 客户端在辅助区域中的只读访问权限

**Aurora 架构**

Amazon Aurora 架构包括以下资源：
+ 在主区域（`us-east-1`）中创建的主 Aurora 数据库集群，具有活动写入器端点
+ 在辅助区域（`us-west-2`）中创建的 Aurora 数据库集群，具有非活动写入器端点
+ DR Orchestrator Framework 同时部署在主要和辅助区域中

![在单个 AWS 账户中部署双区域 Aurora 的示意图。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/8d39561f-924e-4b3e-8175-c5c3cab163bd/images/524ec002-5aa7-47b2-8c8d-6d1a3b535e9e.png)


此图显示以下内容：

1. 主集群和辅助集群之间的异步复制

1. 带有活跃写入器端点的主数据库集群

1. 带有非活跃写入器端点的辅助数据库集群

**ElastiCache (Redis OSS) 架构**

亚马逊 ElastiCache （Redis OSS）架构包括以下资源：
+ 由两个集群创建的 ElastiCache （Redis OSS）全球数据存储：

  1. 主区域（`us-east-1`）中的主集群

  1. 辅助集群位于辅助区域（`us-west-2`）中。
+ 两个集群之间使用 TLS 1.2 加密实现的 Amazon 跨区域链接
+ DR Orchestrator Framework 同时部署在主要和辅助区域中

![带有 Amazon 跨区域链接的双区域 ElastiCache 部署示意图。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/8d39561f-924e-4b3e-8175-c5c3cab163bd/images/cf6620a0-dd42-4042-8dc2-012bf514ffc0.png)


**自动化和扩展**

DR Orchestrator Framework 具有可扩展性，并行支持多个 AWS 数据库的故障转移或故障恢复。

您可以使用以下负载代码对账户中的多个 AWS 数据库进行故障切换。在此示例中，三个 AWS 数据库（两个全球数据库，例如兼容 Aurora MySQL 或兼容 Aurora PostgreSQL 的数据库，以及一个 Amazon RDS for MySQL 实例）故障转移到灾难恢复区域：

```
{
  "StatePayload": [
    {
      "layer": 1,
      "resources": [
        {
          "resourceType": "PlannedFailoverAurora",
          "resourceName": "Switchover (planned failover) of Amazon Aurora global databases (MySQL)",
          "parameters": {
            "GlobalClusterIdentifier": "!Import dr-globaldb-cluster-mysql-global-identifier",
            "DBClusterIdentifier": "!Import dr-globaldb-cluster-mysql-cluster-identifier" 
          }
        },
        {
          "resourceType": "PlannedFailoverAurora",
          "resourceName": "Switchover (planned failover) of Amazon Aurora global databases (PostgreSQL)",
          "parameters": {
            "GlobalClusterIdentifier": "!Import dr-globaldb-cluster-postgres-global-identifier",
            "DBClusterIdentifier": "!Import dr-globaldb-cluster-postgres-cluster-identifier" 
          }
        },
        {
          "resourceType": "PromoteRDSReadReplica",
          "resourceName": "Promote RDS for MySQL Read Replica",
          "parameters": {
            "RDSInstanceIdentifier": "!Import rds-mysql-instance-identifier",
            "TargetClusterIdentifier": "!Import rds-mysql-instance-global-arn"
          }
        }         
      ]
    }
  ]
}
```

## 工具
<a name="automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework-tools"></a>

**AWS 服务**
+ [Amazon Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/CHAP_AuroraOverview.html) 是与 MySQL 和 PostgreSQL 兼容的完全托管式的云端关系数据库引擎。
+ [Amazon ElastiCache](https://docs.aws.amazon.com/elasticache/) 可帮助您在中设置、管理和扩展分布式内存缓存环境。 AWS Cloud这种模式使用亚马逊 ElastiCache （Redis OSS）。
+ [AWS Lambda](https://aws.amazon.com/lambda/) 是一项计算服务，可帮助您运行代码，无需预调配或管理服务器。它只在需要时运行您的代码，并自动进行扩展，因此您只需为使用的计算时间付费。在这种模式中，使用 Lambda 函数 AWS Step Functions 来执行这些步骤。
+ [Amazon Relational Database Service（Amazon RDS）](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html)可帮助您在 AWS Cloud中设置、操作和扩展关系数据库。此模式支持 Amazon RDS for MySQL、Amazon RDS for PostgreSQL 和 Amazon RDS for MariaDB。
+ [适用于 Python (Boto3) 的 AWS SDK](https://aws.amazon.com/sdk-for-python/)帮助您将 Python 应用程序、库或脚本与集成 AWS 服务。在这种模式中，Boto3 APIs 用于与数据库实例或全局数据库通信。
+ [AWS Step Functions](https://aws.amazon.com/step-functions/)是一项无服务器编排服务，可帮助您组合 AWS Lambda 功能和其他功能 AWS 服务 来构建关键业务应用程序。在此模式中，Step Functions 状态机用于编排和运行数据库实例或全局数据库的跨区域故障转移和故障恢复。

**代码存储库**

此模式的代码可在上的 [aws-cross-region-dr GitHub-databases 存储库](https://github.com/aws-samples/aws-cross-region-dr-databases/tree/main/App-Stack)中找到。

## 操作说明
<a name="automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework-epics"></a>

### 安装 DR Orchestrator Framework
<a name="install-dr-orchestrator-framework"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 克隆 GitHub 存储库。 | 要克隆存储库，请运行以下命令：<pre>git clone https://github.com/aws-samples/aws-cross-region-dr-databases.git</pre> | AWS DevOps，AWS 管理员 | 
| 将 Lambda 函数代码打包到 .zip 文件存档中。 | 为 Lambda 函数创建存档文件以包含 DR Orchestrator Framework 依赖项：<pre>cd <YOUR-LOCAL-GIT-FOLDER>/DR-Orchestration-artifacts<br /><br />bash scripts/deploy-orchestrator-sh.sh</pre> | AWS 管理员 | 
| 创建 S3 存储桶。 | 需要使用 S3 存储桶来存储 DR Orchestrator Framework 以及您的最新配置。创建两个 S3 存储桶，一个位于主区域（`us-east-1`）中，一个在辅助区域（`us-west-2`）中：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework.html)<br />将 `xxxxxx` 替换为随机值以使存储桶名称保持唯一。 | AWS 管理员 | 
| 创建子网和安全组。 | 在主区域（`us-east-1`）和辅助区域（`us-west-2`）中，为在您的 VPC 中部署 Lambda 函数创建两个子网和一个安全组：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework.html) | AWS 管理员 | 
| 更新 DR Orchestrator 参数文件。 | 在 `<YOUR-LOCAL-GIT-FOLDER>/DR-Orchestration-artifacts/cloudformation` 文件夹中，更新以下 DR Orchestrator 参数文件：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework.html)<br />使用以下参数值，将 `x` 和 `y` 替换为资源名称：<pre>[<br />    {<br />         "ParameterKey": "TemplateStoreS3BucketName",<br />         "ParameterValue": "dr-orchestrator-xxxxxx-us-east-1"<br />    },<br />    {<br />        "ParameterKey": "TemplateVPCId",<br />        "ParameterValue": "vpc-xxxxxx"<br />    },<br />    {<br />        "ParameterKey": "TemplateLambdaSubnetID1",<br />        "ParameterValue": "subnet-xxxxxx"<br />    },<br />    {<br />        "ParameterKey": "TemplateLambdaSubnetID2",<br />        "ParameterValue": "subnet-yyyyyy"<br />    },<br />    {<br />        "ParameterKey": "TemplateLambdaSecurityGroupID",<br />        "ParameterValue": "sg-xxxxxxxxxx"<br />    }<br /> ]</pre> | AWS 管理员 | 
| 将 DR Orchestrator Framework 代码上传到 S3 存储桶。 | S3 存储桶中的代码比本地目录中的代码更安全。将 `DR-Orchestration-artifacts` 目录（包括所有文件和子文件夹）上传到 S3 存储桶。<br />要上传代码，请执行以下操作：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework.html) | AWS 管理员 | 
| 在主要区域中部署 DR Orchestrator Framework。 | 要在主要区域（`us-east-1`）中部署 DR Orchestrator Framework，请运行以下命令：<pre>cd <YOUR-LOCAL-GIT-FOLDER>/DR-Orchestration-artifacts/cloudformation<br /><br />aws cloudformation deploy \<br />--region us-east-1 \<br />--stack-name dr-orchestrator \<br />--template-file Orchestrator-Deployer.yaml \<br />--parameter-overrides file://Orchestrator-Deployer-parameters-us-east-1.json \<br />--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM \<br />--disable-rollback</pre> | AWS 管理员 | 
| 在辅助区域中部署 DR Orchestrator Framework。 | 在辅助区域（`us-west-2`）中，运行以下命令：<pre>cd <YOUR-LOCAL-GIT-FOLDER>/DR-Orchestration-artifacts/cloudformation<br /><br />aws cloudformation deploy \<br />--region us-west-2 \<br />--stack-name dr-orchestrator \<br />--template-file Orchestrator-Deployer.yaml \<br />--parameter-overrides file://Orchestrator-Deployer-parameters-us-west-2.json \<br />--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM \<br />--disable-rollback</pre> | AWS 管理员 | 
| 验证部署。 | 如果 CloudFormation 命令成功运行，它将返回以下输出：<pre>Successfully created/updated stack - dr-orchestrator</pre><br />或者，您可以导航到 CloudFormation 控制台并验证`dr-orchestrator`堆栈的状态。 | AWS 管理员 | 

### 创建数据库实例或集群
<a name="create-the-database-instances-or-clusters"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建数据库子网和安全组。 | 在您的 VPC 中，在主区域（`us-east-1`）和辅助区域（`us-west-2`）中为数据库实例或全局数据库创建两个子网和一个安全组：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework.html) | AWS 管理员 | 
| 更新主数据库实例或集群的参数文件。 | 在 `<YOUR LOCAL GIT FOLDER>/App-Stack` 文件夹中，更新主要区域的参数文件。<br />**Amazon RDS**<br />在 `RDS-MySQL-parameter-us-east-1.json` 文件中，使用您创建的资源的名称更新 `SubnetIds` 和 `DBSecurityGroup`：<pre>{<br />  "Parameters": {<br />    "SubnetIds": "subnet-xxxxxx,subnet-xxxxxx",<br />    "DBSecurityGroup": "sg-xxxxxxxxxx",<br />    "MySqlGlobalIdentifier":"rds-mysql-instance",<br />    "InitialDatabaseName": "mysqldb",<br />    "DBPortNumber": "3789",<br />    "PrimaryRegion": "us-east-1",<br />    "SecondaryRegion": "us-west-2",<br />    "KMSKeyAliasName": "rds/rds-mysql-instance-KmsKeyId"<br />  }<br />}<br /></pre><br />**Amazon Aurora**<br /> 在 `Aurora-MySQL-parameter-us-east-1.json` 文件中，使用您创建的资源的名称更新 `SubnetIds` 和 `DBSecurityGroup`：<pre>{<br />  "Parameters": {<br />    "SubnetIds": "subnet1-xxxxxx,subnet2-xxxxxx",<br />    "DBSecurityGroup": "sg-xxxxxxxxxx",<br />    "GlobalClusterIdentifier":"dr-globaldb-cluster-mysql",<br />    "DBClusterName":"dbcluster-01",<br />    "SourceDBClusterName":"dbcluster-02",<br />    "DBPortNumber": "3787",<br />    "DBInstanceClass":"db.r5.large",<br />    "InitialDatabaseName": "sampledb",<br />    "PrimaryRegion": "us-east-1",<br />    "SecondaryRegion": "us-west-2",<br />    "KMSKeyAliasName": "rds/dr-globaldb-cluster-mysql-KmsKeyId"<br />  }<br />}</pre><br />**亚马逊 ElastiCache （Redis OSS）**<br />在 `ElastiCache-parameter-us-east-1.json` 文件中，使用您创建的资源的名称更新 `SubnetIds` 和 `DBSecurityGroup`。<pre>{<br />  "Parameters": {<br />    "CacheNodeType": "cache.m5.large",<br />    "DBSecurityGroup": "sg-xxxxxxxxxx",<br />    "SubnetIds": "subnet-xxxxxx,subnet-xxxxxx",<br />    "EngineVersion": "5.0.6",<br />    "GlobalReplicationGroupIdSuffix": "demo-redis-global-datastore",<br />    "NumReplicas": "1",<br />    "NumShards": "1",<br />    "ReplicationGroupId": "demo-redis-cluster",<br />    "DBPortNumber": "3788",<br />    "TransitEncryption": "true",<br />    "KMSKeyAliasName": "elasticache/demo-redis-global-datastore-KmsKeyId",<br />    "PrimaryRegion": "us-east-1",<br />    "SecondaryRegion": "us-west-2"<br />  }<br />}</pre> | AWS 管理员 | 
| 在主要区域中部署数据库实例或集群。 | 要在主区域（`us-east-1`）中部署您的实例或集群，请根据您的数据库引擎运行以下命令。<br />**Amazon RDS**<pre>cd <YOUR-LOCAL-GIT-FOLDER>/App-Stack<br /><br />aws cloudformation deploy \<br />--region us-east-1 \<br />--stack-name rds-mysql-app-stack \<br />--template-file RDS-MySQL-Primary.yaml \<br />--parameter-overrides file://RDS-MySQL-parameter-us-east-1.json \<br />--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM \<br />--disable-rollback</pre><br />**Amazon Aurora**<pre>cd <YOUR-LOCAL-GIT-FOLDER>/App-Stack<br /><br />aws cloudformation deploy \<br />--region us-east-1 \<br />--stack-name aurora-mysql-app-stack \<br />--template-file Aurora-MySQL-Primary.yaml \<br />--parameter-overrides file://Aurora-MySQL-parameter-us-east-1.json \<br />--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM \<br />--disable-rollback</pre><br />**亚马逊 ElastiCache （Redis OSS）**<pre>cd <YOUR-LOCAL-GIT-FOLDER>/App-Stack<br /><br />aws cloudformation deploy \<br />--region us-east-1 --stack-name elasticache-ds-app-stack \<br />--template-file ElastiCache-Primary.yaml \<br />--parameter-overrides file://ElastiCache-parameter-us-east-1.json \<br />--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM \<br />--disable-rollback<br /></pre><br />验证 CloudFormation 资源是否成功部署。 | AWS 管理员 | 
| 更新辅助数据库实例或集群的参数文件。 | 在 `<YOUR LOCAL GIT FOLDER>/App-Stack` 文件夹中，更新辅助区域的参数文件。<br />**Amazon RDS**<br />在 `RDS-MySQL-parameter-us-west-2.json` 文件中，使用您创建的资源的名称更新 `SubnetIDs` 和 `DBSecurityGroup`。`PrimaryRegionKMSKeyArn`使用`MySQLKmsKeyId`从主数据库实例 CloudFormation 堆栈的 O **ut** puts 部分中获取的值更新：<pre>{<br />  "Parameters": {<br />    "SubnetIds": "subnet-aaaaaaaaa,subnet-bbbbbbbbb",<br />    "DBSecurityGroup": "sg-cccccccccc",<br />    "MySqlGlobalIdentifier":"rds-mysql-instance",<br />    "InitialDatabaseName": "mysqldb",<br />    "DBPortNumber": "3789",<br />    "PrimaryRegion": "us-east-1",<br />    "SecondaryRegion": "us-west-2",<br />    "KMSKeyAliasName": "rds/rds-mysql-instance-KmsKeyId",<br />    "PrimaryRegionKMSKeyArn":"arn:aws:kms:us-east-1:xxxxxxxxx:key/mrk-xxxxxxxxxxxxxxxxxxxxx"<br />  }<br />} </pre><br />**Amazon Aurora**<br />在 `Aurora-MySQL-parameter-us-west-2.json` 文件中，使用您创建的资源的名称更新 `SubnetIDs` 和 `DBSecurityGroup`。`PrimaryRegionKMSKeyArn`使用`AuroraKmsKeyId`从主数据库实例 CloudFormation 堆栈的 O **ut** puts 部分中获取的值更新：<pre>{<br />  "Parameters": {<br />    "SubnetIds": "subnet1-aaaaaaaaa,subnet2-bbbbbbbbb",<br />    "DBSecurityGroup": "sg-cccccccccc",<br />    "GlobalClusterIdentifier":"dr-globaldb-cluster-mysql",<br />    "DBClusterName":"dbcluster-01",<br />    "SourceDBClusterName":"dbcluster-02",<br />    "DBPortNumber": "3787",<br />    "DBInstanceClass":"db.r5.large",<br />    "InitialDatabaseName": "sampledb",<br />    "PrimaryRegion": "us-east-1",<br />    "SecondaryRegion": "us-west-2",<br />    "KMSKeyAliasName": "rds/dr-globaldb-cluster-mysql-KmsKeyId"<br />  }<br />}</pre><br />**亚马逊 ElastiCache （Redis OSS）**<br />在 `ElastiCache-parameter-us-west-2.json` 文件中，使用您创建的资源的名称更新 `SubnetIDs` 和 `DBSecurityGroup`。`PrimaryRegionKMSKeyArn`使用`ElastiCacheKmsKeyId`从主数据库实例 CloudFormation 堆栈的 O **ut** puts 部分中获取的值更新：<pre>{<br />  "Parameters": {<br />    "CacheNodeType": "cache.m5.large",<br />    "DBSecurityGroup": "sg-cccccccccc",<br />    "SubnetIds": "subnet-aaaaaaaaa,subnet-bbbbbbbbb",<br />    "EngineVersion": "5.0.6",<br />    "GlobalReplicationGroupIdSuffix": "demo-redis-global-datastore",<br />    "NumReplicas": "1",<br />    "NumShards": "1",<br />    "ReplicationGroupId": "demo-redis-cluster",<br />    "DBPortNumber": "3788",<br />    "TransitEncryption": "true",<br />    "KMSKeyAliasName": "elasticache/demo-redis-global-datastore-KmsKeyId",<br />    "PrimaryRegion": "us-east-1",<br />    "SecondaryRegion": "us-west-2"<br />  }<br />}</pre> | AWS 管理员 | 
| 在辅助区域中部署数据库实例或集群。 | 根据您的数据库引擎运行以下命令。<br />**Amazon RDS**<pre>cd <YOUR-LOCAL-GIT-FOLDER>/App-Stack<br /><br />aws cloudformation deploy \<br />--region us-west-2 \<br />--stack-name rds-mysql-app-stack \<br />--template-file RDS-MySQL-DR.yaml \<br />--parameter-overrides file://RDS-MySQL-parameter-us-west-2.json \<br />--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM \<br />--disable-rollback</pre><br />**Amazon Aurora**<pre>cd <YOUR-LOCAL-GIT-FOLDER>/App-Stack<br /><br />aws cloudformation deploy \<br />--region us-west-2 \<br />--stack-name aurora-mysql-app-stack \<br />--template-file Aurora-MySQL-DR.yaml \<br />--parameter-overrides file://Aurora-MySQL-parameter-us-west-2.json \<br />--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM \<br />--disable-rollback</pre><br />**亚马逊 ElastiCache （Redis OSS）**<pre>cd <YOUR-LOCAL-GIT-FOLDER>/App-Stack<br /><br />aws cloudformation deploy \<br />--region us-west-2 \<br />--stack-name elasticache-ds-app-stack \<br />--template-file ElastiCache-DR.yaml \<br />--parameter-overrides file://ElastiCache-parameter-us-west-2.json \<br />--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM \<br />--disable-rollback</pre><br />验证 CloudFormation 资源是否成功部署。 | AWS 管理员 | 

## 相关资源
<a name="automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework-resources"></a>
+ [数据库的灾难恢复策略 AWS](https://docs.aws.amazon.com/prescriptive-guidance/latest/strategy-database-disaster-recovery/welcome.html)（AWS 规范性指导策略）
+ [在 AWS（AWS 规范性指导指南）上自动执行关系数据库灾难恢复解决方案](https://docs.aws.amazon.com/prescriptive-guidance/latest/automate-dr-solution-relational-database/dr-orchestrator-framework-overview.html)
+ [使用 Amazon Aurora Global Database](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-global-database.html)
+ [跨 AWS 区域 使用全局数据存储进行复制](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Redis-Global-Datastore.html)
+ [在 AWS（AWS 规范性指导指南）上自动执行关系数据库灾难恢复解决方案](https://docs.aws.amazon.com/prescriptive-guidance/latest/automate-dr-solution-relational-database/introduction.html)