

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 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*

## 總結
<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) 區域執行災難復原。模式涵蓋下列資料庫：
+ MySQL 的 Amazon Relational Database Service (Amazon RDS)、PostgreSQL 的 Amazon RDS 或 Amazon RDS for MariaDB
+ Amazon Aurora MySQL 相容版本或 Amazon Aurora PostgreSQL 相容版本 （使用集中式檔案）
+ Amazon ElastiCache (Redis OSS)

若要示範 DR Orchestrator Framework 的功能，您可以建立兩個資料庫執行個體或叢集。主要 位於 AWS 區域 `us-east-1`，次要 位於 `us-west-2`。若要建立這些資源，您可以使用 [aws-cross-region-dr-databases](https://github.com/aws-samples/aws-cross-region-dr-databases) GitHub 儲存庫的 `App-Stack` 資料夾中的 AWS CloudFormation 範本。

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

**一般先決條件**
+ 部署在主要和次要 DR Orchestrator Framework AWS 區域
+ 兩個 [Amazon Simple Storage Service](https://aws.amazon.com/s3/) 儲存貯體
+ 具有兩個子網路和一個 AWS 安全群組的[虛擬私有雲端 (VPC)](https://aws.amazon.com/vpc/) 

**引擎特定的先決條件**
+ **Amazon Aurora** – 至少必須有兩個可用的 Aurora 全域資料庫 AWS 區域。您可以使用 `us-east-1`做為主要區域，並使用 `us-west-2`做為次要區域。
+ **Amazon 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 p****roduct 版本**

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 全域資料庫轉換需要 Aurora MySQL 相容於 MySQL 5.7 相容性，2.09.1 版及更新版本

  如需詳細資訊，請參閱 [Amazon Aurora 全域資料庫的限制](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-global-database.html#aurora-global-database.limitations)。

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

Amazon 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)。

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

**Amazon RDS** **架構**

Amazon RDS 架構包含下列資源：
+ 在主要區域 (`us-east-1`) 中建立的主要 Amazon RDS 資料庫執行個體，具有用戶端的讀取/寫入存取權
+ 在次要區域 (`us-west-2`) 中建立的 Amazon RDS 僅供讀取複本，具有用戶端的唯讀存取權
+ 部署在主要和次要區域的 DR Orchestrator Framework

![單一 AWS 帳戶中雙區域 RDS 架構的圖表。](http://docs.aws.amazon.com/zh_tw/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_tw/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) 架構**

Amazon 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_tw/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 執行個體） 容錯移轉至 DR 區域：

```
{
  "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 雲端。此模式使用 Amazon 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 雲端。此模式支援 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 狀態機器用於協調和執行資料庫執行個體或全域資料庫的跨區域容錯移轉和容錯回復。

**程式碼儲存庫**

此模式的程式碼可在 GitHub 上的 [aws-cross-region-dr-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>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 複製 GitHub 儲存庫。 | 若要複製儲存庫，請執行下列命令：<pre>git clone https://github.com/aws-samples/aws-cross-region-dr-databases.git</pre> | AWS DevOps、AWS 管理員 | 
| 在 .zip 檔案封存中封裝 Lambda 函數程式碼。 | 建立 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_tw/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_tw/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_tw/prescriptive-guidance/latest/patterns/automate-cross-region-failover-and-failback-by-using-dr-orchestrator-framework.html)<br />使用下列參數值，`y`將 `x`和 取代為您的資源名稱：<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_tw/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>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立資料庫子網路和安全群組。 | 在您的 VPC 中，為主要 (`us-east-1`) 和次要 (`us-west-2`) 區域中的資料庫執行個體或全域資料庫建立兩個子網路和一個安全群組：[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_tw/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` 檔案中，`DBSecurityGroup`使用您建立的資源名稱更新 `SubnetIds`和 ：<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` 檔案中，`DBSecurityGroup`使用您建立的資源名稱更新 `SubnetIds`和 ：<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 />**Amazon ElastiCache (Redis OSS)**<br />在 `ElastiCache-parameter-us-east-1.json` 檔案中，`DBSecurityGroup`使用您建立的資源名稱更新 `SubnetIds`和 。<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 />**Amazon 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` 檔案中，`DBSecurityGroup`使用您建立的資源名稱更新 `SubnetIDs`和 。`PrimaryRegionKMSKeyArn` 使用從 CloudFormation 主要資料庫執行個體堆疊的**輸出**區段`MySQLKmsKeyId`取得的 值來更新 ：<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` 檔案中，`DBSecurityGroup`使用您建立的資源名稱更新 `SubnetIDs`和 。`PrimaryRegionKMSKeyArn` 使用`AuroraKmsKeyId`取自主要資料庫執行個體 CloudFormation 堆疊輸出****區段的 值來更新 ：<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 />**Amazon ElastiCache (Redis OSS)**<br />在 `ElastiCache-parameter-us-west-2.json` 檔案中，`DBSecurityGroup`使用您建立的資源名稱更新 `SubnetIDs`和 。`PrimaryRegionKMSKeyArn` 使用`ElastiCacheKmsKeyId`取自主要資料庫執行個體 CloudFormation 堆疊輸出****區段的 值更新 ：<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 />**Amazon 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 方案指引策略）
+ [自動化 上關聯式資料庫的 DR 解決方案 AWS](https://docs.aws.amazon.com/prescriptive-guidance/latest/automate-dr-solution-relational-database/dr-orchestrator-framework-overview.html) (AWS 方案指引指南）
+ [使用 Amazon Aurora 全球資料庫](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)
+ [自動化 上關聯式資料庫的 DR 解決方案 AWS](https://docs.aws.amazon.com/prescriptive-guidance/latest/automate-dr-solution-relational-database/introduction.html) (AWS 方案指引指南）