

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

# 購買 Amazon RDS 的預留資料庫執行個體
<a name="USER_WorkingWithReservedDBInstances.WorkingWith"></a>

您可以使用 AWS 管理主控台 AWS CLI、 和 RDS API 來使用預留資料庫執行個體。

## 主控台
<a name="USER_WorkingWithReservedDBInstances.CON"></a>

您可以使用 AWS 管理主控台 來處理預留資料庫執行個體，如下列程序所示。

**取得可用的預留資料庫執行個體方案的定價與資訊**

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

1. 在導覽窗格中，選擇 **Reserved instances** (預留執行個體)。

1. 選擇 **Purchase Reserved DB Instance (購買預留資料庫執行個體)**。

1. 在 **Product description (產品說明)** 中，選擇資料庫引擎和授權類型。

1. 在 **DB instance class (資料庫執行個體類別)** 中，選擇資料庫執行個體類別。

1. 針對**部署選項**，選擇您要單一可用區還是多可用區資料庫執行個體部署。
**注意**  
若要為多可用區資料庫叢集部署購買同等的預留資料庫執行個體，請購買三個單一可用區預留資料庫執行個體，或者購買一個多可用區和一個單一可用區預留資料庫執行個體。如需詳細資訊，請參閱[多可用區域資料庫叢集的預留資料庫執行個體](USER_WorkingWithReservedDBInstances.md#USER_WorkingWithReservedDBInstances.MultiAZDBClusters)。

1. 在**期限**中，選擇您想要預留資料庫執行個體的時間長度。

1. 在 **Offering type (方案類型)** 中，選擇方案類型。

   選擇方案類型後，便會顯示定價資訊。
**重要**  
選擇 **Cancel (取消)**，將不會購買預留資料庫執行個體，也不會產生任何費用。

取得可用的預留資料庫執行個體方案資訊後，您便能利用這些資訊來購買方案，如以下程序所示。

**購買預留資料庫執行個體**

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

1. 在導覽窗格中，選擇 **Reserved instances** (預留執行個體)。

1. 
**重要**  
繼續操作前，請先確認您位於正確的 AWS 區域中。預留資料庫執行個體具有區域性，且無法在區域之間轉移。請查看主控台右上角的區域選擇器，以確保您是在預期的區域中購買預留執行個體。

1. 選擇 **Purchase reserved DB instance** (購買預留資料庫執行個體)。

1. 在 **Product description (產品說明)** 中，選擇資料庫引擎和授權類型。

1. 在 **DB instance class (資料庫執行個體類別)** 中，選擇資料庫執行個體類別。

1. 在**多可用區部署**中，選擇您要單一可用區還是多可用區資料庫執行個體部署。
**注意**  
若要為多可用區資料庫叢集部署購買同等的預留資料庫執行個體，請購買三個單一可用區預留資料庫執行個體，或者購買一個多可用區和一個單一可用區預留資料庫執行個體。如需詳細資訊，請參閱[多可用區域資料庫叢集的預留資料庫執行個體](USER_WorkingWithReservedDBInstances.md#USER_WorkingWithReservedDBInstances.MultiAZDBClusters)。

1. 在 **Term (期限)** 中，選擇您想要預留資料庫執行個體的時間長度。

1. 在 **Offering type (方案類型)** 中，選擇方案類型。

   選擇方案類型後，便會顯示定價資訊。  
![\[購買預留資料庫執行個體主控台\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/UserGuide/images/reservedinstance.png)

1. (選用) 您可將自己的識別碼指派至所購買的預留執行個體，以協助您追蹤這些執行個體。針對 **Reserved Id (預留 ID)** 中，輸入預留資料庫執行個體的識別碼。

1. 選擇**提交**。

   您的預留資料庫執行個體已購買，然後顯示在 **Reserved instances** (預留執行個體) 清單中。

購買預留資料庫執行個體後，您將取得預留資料庫執行個體的資訊，如以下程序所示。

**取得 AWS 您帳戶預留資料庫執行個體的相關資訊**

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

1. 在 **Navigation (導覽)** 窗格中，選擇 **Reserved instances (預留執行個體)**。

   將顯示您帳戶的預留資料庫執行個體。若要查看特定預留資料庫執行個體的詳細資訊，請選擇清單中的該執行個體。在主控台底端的詳細資訊窗格中，您即可看到該執行個體的詳細資訊。

## AWS CLI
<a name="USER_WorkingWithReservedDBInstances.CLI"></a>

您可以使用 AWS CLI 來使用預留資料庫執行個體，如下列範例所示。

**Example 取得可用的預留資料庫執行個體方案**  
若要取得可用預留資料庫執行個體產品的相關資訊，請呼叫 AWS CLI 命令 [https://docs.aws.amazon.com/cli/latest/reference/rds/describe-reserved-db-instances-offerings.html](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-reserved-db-instances-offerings.html)。  

```
aws rds describe-reserved-db-instances-offerings
```
此呼叫會傳回類似以下的輸出：  

```
 1. OFFERING  OfferingId                            Class         Multi-AZ  Duration  Fixed Price  Usage Price  Description  Offering Type
 2. OFFERING  438012d3-4052-4cc7-b2e3-8d3372e0e706  db.r3.large   y         1y        1820.00 USD  0.368 USD    mysql        Partial  Upfront
 3. OFFERING  649fd0c8-cf6d-47a0-bfa6-060f8e75e95f  db.r3.small   n         1y         227.50 USD  0.046 USD    mysql        Partial  Upfront
 4. OFFERING  123456cd-ab1c-47a0-bfa6-12345667232f  db.r3.small   n         1y         162.00 USD   0.00 USD    mysql        All      Upfront
 5.     Recurring Charges:   Amount  Currency  Frequency        
 6.     Recurring Charges:   0.123   USD       Hourly
 7. OFFERING  123456cd-ab1c-37a0-bfa6-12345667232d  db.r3.large   y         1y         700.00 USD   0.00 USD    mysql        All      Upfront
 8.     Recurring Charges:   Amount  Currency  Frequency
 9.     Recurring Charges:   1.25    USD       Hourly
10. OFFERING  123456cd-ab1c-17d0-bfa6-12345667234e  db.r3.xlarge  n         1y        4242.00 USD   2.42 USD    mysql        No       Upfront
```

取得可用的預留資料庫執行個體方案資訊後，您便能利用這些資訊來購買方案。

若要購買預留資料庫執行個體，請使用 AWS CLI 命令[https://docs.aws.amazon.com/cli/latest/reference/rds/purchase-reserved-db-instances-offering.html](https://docs.aws.amazon.com/cli/latest/reference/rds/purchase-reserved-db-instances-offering.html)搭配下列參數：
+ `--reserved-db-instances-offering-id` – 您想要購買之方案的 ID。請參閱上述範例，取得方案的 ID。
+ `--reserved-db-instance-id` – 您可將自己的識別符指派至所購買的預留資料庫執行個體，以幫助追蹤這些執行個體。

**Example 購買預留資料庫執行個體**  
下列範例將購買 ID *649fd0c8-cf6d-47a0-bfa6-060f8e75e95f* 的預留資料庫執行個體方案，並指派識別碼 *MyReservation*。  
對於 Linux、macOS 或 Unix：  

```
aws rds purchase-reserved-db-instances-offering \
    --reserved-db-instances-offering-id 649fd0c8-cf6d-47a0-bfa6-060f8e75e95f \
    --reserved-db-instance-id MyReservation
```
在 Windows 中：  

```
aws rds purchase-reserved-db-instances-offering ^
    --reserved-db-instances-offering-id 649fd0c8-cf6d-47a0-bfa6-060f8e75e95f ^
    --reserved-db-instance-id MyReservation
```
此命令會傳回類似以下的輸出：  

```
1. RESERVATION  ReservationId      Class        Multi-AZ  Start Time                Duration  Fixed Price  Usage Price  Count  State            Description  Offering Type
2. RESERVATION  MyReservation      db.r3.small  y         2011-12-19T00:30:23.247Z  1y        455.00 USD   0.092 USD    1      payment-pending  mysql        Partial  Upfront
```

購買預留資料庫執行個體後，您將取得預留資料庫執行個體的資訊。

若要取得 AWS 您帳戶預留資料庫執行個體的相關資訊，請呼叫 AWS CLI 命令 [https://docs.aws.amazon.com/cli/latest/reference/rds/describe-reserved-db-instances.html](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-reserved-db-instances.html)，如下列範例所示。

**Example 取得您的預留資料庫執行個體**  

```
aws rds describe-reserved-db-instances
```
此命令會傳回類似以下的輸出：  

```
1. RESERVATION  ReservationId     Class        Multi-AZ  Start Time                Duration  Fixed Price  Usage Price  Count  State    Description  Offering Type
2. RESERVATION  MyReservation     db.r3.small  y         2011-12-09T23:37:44.720Z  1y        455.00 USD   0.092 USD    1      retired  mysql        Partial  Upfront
```

## RDS API
<a name="USER_WorkingWithReservedDBInstances.API"></a>

您可以使用 RDS API 來處理預留資料庫執行個體︰
+ 若要取得可用的預留資料庫執行個體方案資訊，請呼叫 Amazon RDS API 操作 [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeReservedDBInstancesOfferings.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeReservedDBInstancesOfferings.html)。
+ 取得可用的預留資料庫執行個體方案資訊後，您便能利用這些資訊來購買方案。請使用下列參數呼叫 [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_PurchaseReservedDBInstancesOffering.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_PurchaseReservedDBInstancesOffering.html) RDS API 操作：
  + `--reserved-db-instances-offering-id` – 您想要購買之方案的 ID。
  + `--reserved-db-instance-id` – 您可將自己的識別符指派至所購買的預留資料庫執行個體，以幫助追蹤這些執行個體。
+ 購買預留資料庫執行個體後，您將取得預留資料庫執行個體的資訊。請呼叫 [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeReservedDBInstances.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeReservedDBInstances.html) RDS API 操作。