

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

# 建立 AWS Outposts 上的 Amazon RDS 的資料庫執行個體
<a name="rds-on-outposts.creating"></a>

建立 AWS Outposts 上的 Amazon RDS 資料庫執行個體類似於在 AWS 雲端建立 Amazon RDS 資料庫執行個體。不過，請務必指定與 Outpost 相關聯的資料庫子網路群組。

以 Amazon VPC 服務為基礎的 Virtual Private Cloud (VPC) 可以跨越 AWS 區域 中的所有可用區域。您可新增 Outpost 子網路，將 AWS 區域 中的任何 VPC 延伸至 Outpost。若要將 Outpost 子網路新增至 VPC，請在建立子網路時指定 Outpost 的 Amazon Resource Name (ARN)。

建立 Outposts 上的 RDS 資料庫執行個體之前，您可以建立資料庫子網路群組，其中包含一個與 Outpost 相關聯的子網路。建立 Outposts 上的 RDS 資料庫執行個體時，請指定此資料庫子網路群組。您也可以選擇在建立資料庫執行個體時，建立新的資料庫子網路群組。

如需如何設定 AWS Outposts 的資訊，請參閱 [AWS Outposts 使用者指南](https://docs.aws.amazon.com/outposts/latest/userguide/)。

## 主控台
<a name="rds-on-outposts.creating.console"></a>

### 建立資料庫子網路群組
<a name="rds-on-outposts.creating.console.subnet"></a>

建立資料庫子網路群組，其中包含一個與 Outpost 相關聯的子網路。

您也可以在建立資料庫執行個體時，建立 Outpost 的新資料庫子網路群組。如果您希望執行此作業，請略過此程序。

**注意**  
若要為 AWS 雲端 建立資料庫子網路群組，請指定至少兩個子網路。

**若要建立 Outpost 的資料庫子網路群組**

1. 登入 AWS 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1. 在 Amazon RDS 主控台的右上角，選擇您要建立資料庫子網路群組的 AWS 區域。

1. 選擇 **Subnet groups** (子網路群組)，然後選擇 **Create DB Subnet Group** (建立資料庫子網路群組)。

   **Create DB subnet group** (建立資料庫子網路群組) 頁面隨即出現。  
![\[「建立資料庫子網路群組」頁面。\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/UserGuide/images/create-db-subnet-group.png)

1. 針對 **Name (名稱)**，輸入資料庫子網路群組的名稱。

1. 針對 **Description (描述)**，選擇資料庫子網路群組的描述。

1. 針對 **VPC**，選擇您想為其建立資料庫子網路群組的 VPC。

1. 在**可用區域**中，選擇 Outpost 的可用區域。

1. 在**子網路**中，選擇供 Outposts 上的 RDS 使用的子網路。

1. 選擇 **Create** (建立) 來建立資料庫子網路群組。

### 建立 RDS on Outposts 資料庫執行個體
<a name="rds-on-outposts.creating.console.DB"></a>

建立資料庫執行個體，然後選擇資料庫執行個體的 Outpost。

**使用主控台建立 Outposts 上的 RDS 資料庫執行個體**

1. 登入 AWS 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1. 在 Amazon RDS 主控台的右上角，選擇要在其上建立資料庫執行個體之 Outpost 所附加的 AWS 區域。

1. 在導覽窗格中，選擇 **Databases** (資料庫)。

1. 選擇 **Create database** (建立資料庫)。

   AWS 管理主控台 會偵測您已設定的可用 Outposts，並在**資料庫位置**區段中顯示**內部部署**選項。
**注意**  
如果您尚未設定任何 Outposts，則表示**資料庫位置**區段沒有出現，或**選擇內部部署建立方法**區段中沒有 **Outposts 上的 RDS** 選項。

1. 針對 **Database location (資料庫位置)**，選擇 **On-premises (內部部署)**。

1. 針對 **On-premises creation method (內部部署建立方法)**，選擇 **RDS on Outposts**。

1. 指定 **Outposts Connectivity (Outposts 連線能力)** 的設定。這些設定適用於使用 VPC (具有資料庫執行個體的資料庫子網路) 的 Outpost。您的 VPC 必須以 Amazon VPC 服務為基礎。

   1. 針對 **Virtual Private Cloud (VPC)**，選擇包含資料庫執行個體之資料庫子網路群組的 VPC。

   1. 針對 **VPC security group (VPC 安全群組)**，選擇適用於您的資料庫執行個體的 Amazon VPC 安全群組。

   1. 針對 **DB Subnet group** (資料庫子網路群組)，選擇適用於您的資料庫執行個體的資料庫子網路群組。

      您可選擇與 Outpost 相關聯的現有資料庫子網路群組—例如，若您執行 [建立資料庫子網路群組](#rds-on-outposts.creating.console.subnet) 中的程序。

      您也可以為 Outpost 建立新的資料庫子網路群組。

1. 若為 **Multi-AZ deployment (異地同步備份部署)**，請選擇 **Create a standby instance (recommended for production usage)(建立備用執行個體，推薦用於生產用途)**，在另一個 Outpost 中建立備用資料庫執行個體。
**注意**  
此選項無法用於 Microsoft SQL Server。  
若選擇建立異地同步備份部署，則無法將備份存放於 Outpost 上。

1. 在 **Backup (備份)** 底下，執行下列動作：

   1. 針對 **Backup target (備份目標)**，選擇下列其中一項：
      + **AWS 雲端** 在父系 AWS 區域 中存放自動備份和手動快照。
      + **Outposts (on-premises) (Outposts (現場部署))** 以建立本機備份。
**注意**  
如要在您的 Outpost 上存放備份，您的 Outpost 必須具有 Simple Storage Service (Amazon S3) 功能。如需詳細資訊，請參閱 [Amazon S3 on Outposts](https://aws.amazon.com/s3/outposts/)。  
多可用區部署或僅供讀取複本不支援本機備份。

   1. 選擇 **Enable automated backups** (啟用自動備份) 以建立資料庫執行個體的時間點快照。

      若您開啟自動備份，則可選擇 **Backup retention period (備份保留期)** 和 **Backup window (備份時段)**，或保留預設值。

1. 視需要指定其他資料庫執行個體設定。

   如需建立資料庫執行個體時各項設定的相關資訊，請參閱 [資料庫執行個體的設定](USER_CreateDBInstance.Settings.md)。

1. 選擇 **Create database** (建立資料庫)。

   **Databases** (資料庫) 頁面隨即出現。橫幅告訴您正在建立資料庫執行個體，並顯示 **View credential details** (檢視憑證詳細資訊) 按鈕。

### 檢視資料庫執行個體詳細資訊
<a name="rds-on-outposts.creating.console.view"></a>

建立資料庫執行個體之後，您可以檢視其憑證和其他詳細資訊。

**若要檢視資料庫執行個體詳細資訊**

1. 若要檢視資料庫執行個體的主要使用者名稱和密碼，請選擇 **Databases** (資料庫) 頁面上的 **View credential details** (檢視憑證詳細資訊)。

   您可以使用這些憑證，以主要使用者身分連線至資料庫執行個體。
**重要**  
您無法再次檢視主要使用者密碼。如果您沒有記錄下來，您可能需要進行變更。若要在資料庫執行個體可供使用後變更主要使用者密碼，請修改資料庫執行個體。如需修改 資料庫執行個體的詳細資訊，請參閱[修改 Amazon RDS 資料庫執行個體](Overview.DBInstance.Modifying.md)。

1. 在 **Databases** (資料庫) 頁面上，選擇新資料庫執行個體的名稱。

   在 RDS 主控台上，新資料庫執行個體的詳細資訊即會出現。在資料庫執行個體建立完成且可供使用之前，資料庫執行個體會處於 **Creating (建立中)** 狀態。狀態變更為 **Available (可用)** 時，您便能連線至資料庫執行個體。視資料庫執行個體類別和分配的儲存空間而定，新的資料庫執行個體可能需要幾分鐘才能使用。  
![\[我的資料庫執行個體詳細資訊\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/UserGuide/images/create-outpost-launch.png)

   在資料庫執行個體可供使用之後，管理起來就像在 AWS 雲端 中管理 RDS 資料庫執行個體一樣。

## AWS CLI
<a name="rds-on-outposts.creating.cli"></a>

在 Outpost 中使用 AWS CLI 建立新的資料庫執行個體之前，請先建立資料庫子網路群組，以供 RDS on Outposts 使用。

**若要建立 Outpost 的資料庫子網路群組**
+ 使用 [create-db-subnet-group](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-subnet-group.html) 命令。針對 `--subnet-ids`，指定 Outpost 中的子網路群組，以供 RDS on Outposts 使用。

  針對 Linux、macOS 或 Unix：

  ```
  1. aws rds create-db-subnet-group \
  2.     --db-subnet-group-name myoutpostdbsubnetgr \
  3.     --db-subnet-group-description "DB subnet group for RDS on Outposts" \
  4.     --subnet-ids subnet-abc123
  ```

  針對 Windows：

  ```
  1. aws rds create-db-subnet-group ^
  2.     --db-subnet-group-name myoutpostdbsubnetgr ^
  3.     --db-subnet-group-description "DB subnet group for RDS on Outposts" ^
  4.     --subnet-ids subnet-abc123
  ```

**若要使用 AWS CLI 建立 RDS on Outposts 資料庫執行個體**
+ 使用 [create-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-instance.html) 命令。指定 Outpost 的可用區域、與 Outpost 建立關聯的 Amazon VPC 安全群組，以及為 Outpost 建立的資料庫子網路群組。可以包含下列選項：
  + `--db-instance-identifier`
  + `--db-instance-class`
  + `--engine` – 資料庫引擎。使用以下其中一個值：
    + MySQL – 指定 `mysql`。
    + PostgreSQL – 指定 `postgres`。
    + Microsoft SQL Server – 指定 `sqlserver-ee`、`sqlserver-se`、 或 `sqlserver-web`。
  + `--availability-zone`
  + `--vpc-security-group-ids`
  + `--db-subnet-group-name`
  + `--allocated-storage`
  + `--max-allocated-storage`
  + `--master-username`
  + `--master-user-password`
  + `--multi-az | --no-multi-az` – (選用) 是否在不同的可用區域建立備用資料庫執行個體。預設值為 `--no-multi-az`。

    `--multi-az` 選項無法用於 SQL Server。
  + `--backup-retention-period`
  + `--backup-target` – (選用) 存放自動備份和手動快照的位置。使用以下其中一個值：
    + `outposts` – 將它們本機存放在您的 Outpost 上。
    + `region` – 將其存放於父系 AWS 區域 中。這是預設值。

    若您使用 `--multi-az` 選項，則無法使用 `--backup-target` 的 `outposts`。此外，如果您將 `outposts` 用於 `--backup-target`，資料庫執行個體就無法具有僅供讀取複本。
  + `--storage-encrypted`
  + `--kms-key-id`

**Example**  
下列範例會建立名為 `myoutpostdbinstance` 的 MySQL 資料庫執行個體，其備份存放在您的 Outpost 上。  
針對 Linux、macOS 或 Unix：  

```
 1. aws rds create-db-instance \
 2.     --db-instance-identifier myoutpostdbinstance \
 3.     --engine-version 8.0.17 \
 4.     --db-instance-class db.m5.large \
 5.     --engine mysql \
 6.     --availability-zone us-east-1d \
 7.     --vpc-security-group-ids outpost-sg \
 8.     --db-subnet-group-name myoutpostdbsubnetgr \
 9.     --allocated-storage 100 \
10.     --max-allocated-storage 1000 \
11.     --master-username masterawsuser \
12.     --manage-master-user-password \
13.     --backup-retention-period 3 \
14.     --backup-target outposts \
15.     --storage-encrypted \
16.     --kms-key-id mykey
```
針對 Windows：  

```
 1. aws rds create-db-instance ^
 2.     --db-instance-identifier myoutpostdbinstance ^
 3.     --engine-version 8.0.17 ^
 4.     --db-instance-class db.m5.large ^
 5.     --engine mysql ^
 6.     --availability-zone us-east-1d ^
 7.     --vpc-security-group-ids outpost-sg ^
 8.     --db-subnet-group-name myoutpostdbsubnetgr ^
 9.     --allocated-storage 100 ^
10.     --max-allocated-storage 1000 ^
11.     --master-username masterawsuser ^
12.     --manage-master-user-password ^
13.     --backup-retention-period 3 ^
14.     --backup-target outposts ^
15.     --storage-encrypted ^
16.     --kms-key-id mykey
```

如需建立資料庫執行個體時各項設定的相關資訊，請參閱 [資料庫執行個體的設定](USER_CreateDBInstance.Settings.md)。

## RDS API
<a name="rds-on-outposts.creating.api"></a>

若要使用 RDS API 在 Outpost 中建立新的資料庫執行個體，請先呼叫 [CreateDBSubnetGroup](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBSubnetGroup.html) 操作，以建立可供 Outposts 上的 RDS 使用的資料庫子網路群組。針對 `SubnetIds`，指定 Outpost 中的子網路群組，以供 RDS on Outposts 使用。

接下來，請以下列參數呼叫 [CreateDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html) 作業。指定 Outpost 的可用區域、與 Outpost 建立關聯的 Amazon VPC 安全群組，以及為 Outpost 建立的資料庫子網路群組。
+ `AllocatedStorage`
+ `AvailabilityZone`
+ `BackupRetentionPeriod`
+ `BackupTarget`

  如果您要建立多可用區域資料庫執行個體部署，則無法將 `outposts` 用於 `BackupTarget`。此外，如果您將 `outposts` 用於 `BackupTarget`，資料庫執行個體就無法具有僅供讀取複本。
+ `DBInstanceClass`
+ `DBInstanceIdentifier`
+ `VpcSecurityGroupIds`
+ `DBSubnetGroupName`
+ `Engine`
+ `EngineVersion`
+ `MasterUsername`
+ `MasterUserPassword`
+ `MaxAllocatedStorage` (選用)
+ `MultiAZ` (選用)
+ `StorageEncrypted`
+ `KmsKeyID`

如需建立資料庫執行個體時各項設定的相關資訊，請參閱 [資料庫執行個體的設定](USER_CreateDBInstance.Settings.md)。