

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

# 建立並連線至 Amazon RDS Custom for SQL Server 的資料庫執行個體
<a name="custom-creating-sqlserver"></a>

您可以建立 RDS Custom 資料庫執行個體，然後使用 AWS Systems Manager 或遠端桌面通訊協定 (RDP) 連線到該執行個體。

**重要**  
您必須完成 [設定您的 Amazon RDS Custom for SQL Server 的環境](custom-setup-sqlserver.md) 中的任務，才能建立或連線至 RDS Custom for SQL Server 資料庫執行個體。  
當您建立 RDS Custom 資料庫執行個體時可以為它加上標籤，但是請勿建立或修改 RDS Custom 自動化所需的 `AWSRDSCustom` 標籤。如需詳細資訊，請參閱[標記 RDS Custom for SQL Server 資源](custom-managing-sqlserver.tagging.md)。  
第一次建立 RDS Custom for SQL Server 資料庫執行個體時，您可能會收到下列錯誤：服務連結角色正在建立的程序中。請稍後再試。如果收到這個訊息，請等待幾分鐘的時間然後再次嘗試建立資料庫執行個體。

**Topics**
+ [建立 RDS Custom for SQL Server 資料庫執行個體](#custom-creating-sqlserver.create)
+ [RDS Custom 服務連結角色](custom-creating-sqlserver.slr.md)
+ [使用 連線至 RDS Custom 資料庫執行個體 AWS Systems Manager](custom-creating-sqlserver.ssm.md)
+ [使用 RDS 連線到您的 RDS Custom 資料庫執行個體](custom-creating-sqlserver.rdp.md)

## 建立 RDS Custom for SQL Server 資料庫執行個體
<a name="custom-creating-sqlserver.create"></a>

使用 AWS 管理主控台 或 建立 Amazon RDS Custom for SQL Server 資料庫執行個體 AWS CLI。該程序與建立 Amazon RDS 資料庫執行個體的程序類型。

如需詳細資訊，請參閱[建立 Amazon RDS 資料庫執行個體](USER_CreateDBInstance.md)。

### 主控台
<a name="custom-creating-sqlserver.CON"></a>

**若要建立 RDS Custom for SQL Server 資料庫執行個體**

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

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

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

1. 選擇 **Standard Create** (標準建立) 做為資料庫建立方法。

1. 針對 **Engine options (引擎選項)**，選擇 **Microsoft SQL Server** 做為引擎類型。

1. 針對 **Database management type (引擎管理類型)**，選擇 **Amazon RDS Custom**。

1. 在 **Edition** (版本) 區段中，選擇您想要使用的資料庫引擎版本。

1. (選用) 如果您想要從 CEV 建立資料庫執行個體，請核取 **Use custom engine version (CEV)** (使用自訂引擎版本 (CEV)) 核取方塊。在下拉式清單中選取您的 CEV。

1. 針對**資料庫版本**，保留 SQL Server 2019 預設值。

1. 在 **Templates** (範本) 中，選擇 **Production** (生產)。

1. 在 **Settings** (設定) 區段中，為 **DB instance identifier** (資料庫執行個體識別符) 輸入唯一的名稱。

1. 若要輸入您的主要密碼，請執行以下動作：

   1. 在 **Settings (設定)** 區段，開啟 **Credential Settings (登入資料設定)**。

   1. 清除 **Auto generate a password (自動產生密碼)** 核取方塊。

   1. 變更 **Master username (主要使用者名稱)** 值並在 **Master password (主要密碼)** 和 **Confirm password (確認密碼)** 中輸入相同的密碼。

   根據預設，新 RDS Custom 資料庫執行個體會將自動產生的密碼用於主要使用者。

1. 在 **DB instance size** (資料庫執行個體大小) 區段中，為 **DB instance class** (資料庫執行個體類別) 選擇值。

   如需支援的類別，請參閱 [RDS Custom for SQL Server 的資料庫執行個體類別支援](custom-reqs-limits.instancesMS.md)。

1. 選擇 **Storage (儲存)** 設定。

1. 針對 **RDS Custom security (RDS Custom 安全)**，請執行下列操作：

   1. 針對 **IAM 執行個體設定檔**，您有兩個選項可為您的 RDS Custom for SQL Server 資料庫執行個體選擇執行個體設定檔。

      1. 選擇**建立新的執行個體描述檔**，並提供執行個體描述檔名稱尾碼。如需詳細資訊，請參閱[使用 自動建立執行個體描述檔 AWS 管理主控台](custom-setup-sqlserver.md#custom-setup-sqlserver.instanceProfileCreation)。

      1. 選擇現有的執行個體設定檔。從下拉式清單中，選擇開頭為 `AWSRDSCustom` 的執行個體設定檔。

   1. 針對 **Encryption (加密)**，選擇 **Enter a key ARN (輸入金鑰 ARN)** 以列出可用的 AWS KMS 金鑰。然後從清單選擇您的金鑰。

      RDS Custom 需要 AWS KMS 金鑰。如需詳細資訊，請參閱[請確定您有對稱加密 AWS KMS 金鑰](custom-setup-sqlserver.md#custom-setup-sqlserver.cmk)。

1. 在其餘區段，指定您偏好的 RDS Custom 資料庫執行個體的設定。如需每項設定的相關資訊，請參閱 [資料庫執行個體的設定](USER_CreateDBInstance.Settings.md)。以下設定不會出現在主控台中，也不受支援：
   + **處理器功能**
   + **儲存體自動調整規模**
   + **Availability & durability (可用性與持久性)**
   + **Database authentication (資料庫身分驗證)** 中的 **Password and Kerberos authentication (密碼和 Kerberos 身分驗證)** 選項 (僅支援 **Password authentication (密碼身分驗證)**)
   + **Additional configuration (其他組態)** 中的 **Database options (資料庫選項)**
   + **Performance Insights** (績效詳情)
   + **Log exports (日誌匯出)**
   + **Enable auto minor version upgrade (啟用自動次要版本升級)**
   + **刪除保護**

   支援 **Backup retention period (備份保留期)**，但是您無法選擇 **0 days (0 天)**。

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

   **View credential details** (檢視憑證詳細資訊) 按鈕會顯示在 **Databases** (資料庫) 頁面上。

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

   若要以主要使用者的身分連線至資料庫執行個體，請使用出現的使用者名稱和密碼。
**重要**  
您無法再次檢視主要使用者密碼。如果您沒有記錄下來，您可能需要進行變更。若要在 RDS Custom 資料庫執行個體可供使用後變更主要使用者密碼，請修改資料庫執行個體。如需修改 資料庫執行個體的詳細資訊，請參閱[管理 Amazon RDS Custom for SQL Server 資料庫執行個體](custom-managing-sqlserver.md)。

1. 選擇 **Databases** (資料庫) 以檢視 RDS Custom 資料庫執行個體的清單。

1. 選擇您剛剛建立的 RDS Custom 資料庫執行個體。

   在 RDS 主控台上，新 RDS Custom 資料庫執行個體的詳細資訊即會出現：
   + 在 RDS Custom 資料庫執行個體建立完成且可供使用之前，資料庫執行個體會處於 **Creating (建立中)** 狀態。狀態變更為 **Available (可用)** 時，您便能連線至資料庫執行個體。視執行個體類別和分配的儲存空間而定，新的資料庫執行個體可能需要幾分鐘才能使用。
   + **Role (角色)** 具有 **Instance (RDS Custom) (執行個體 (RDS Custom))** 值。
   + **RDS Custom automation mode** (RDS Custom 自動化模式) 具有 **Full automation** (全自動化) 值。此設定表示資料庫執行個體提供自動監控和執行個體復原。

### AWS CLI
<a name="custom-creating-sqlserver.CLI"></a>

您可以使用 [create-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-instance.html) AWS CLI 命令建立 RDS Custom 資料庫執行個體。

下列選項是必要的：
+ `--db-instance-identifier`
+ `--db-instance-class` (如需支援執行個體類別的清單，請參閱 [RDS Custom for SQL Server 的資料庫執行個體類別支援](custom-reqs-limits.instancesMS.md))
+ `--engine` (`custom-sqlserver-ee`、`custom-sqlserver-se` 或 `custom-sqlserver-web`)
+ `--kms-key-id`
+ `--custom-iam-instance-profile`

下列範例會建立名稱為 `my-custom-instance` 的 RDS Custom for SQL Server 資料庫執行個體。備份保留期為 3 天。

**注意**  
若要從自訂引擎版本 (CEV) 建立資料庫執行個體，請將現有的 CEV 名稱提供給 `--engine-version` 參數。例如 `--engine-version 15.00.4249.2.my_cevtest`

**Example**  
在 Linux、macOS 或 Unix 中：  

```
 1. aws rds create-db-instance \
 2.     --engine {{custom-sqlserver-ee}} \
 3.     --engine-version {{15.00.4073.23.v1}} \
 4.     --db-instance-identifier {{my-custom-instance}} \
 5.     --db-instance-class {{db.m5.xlarge}} \
 6.     --allocated-storage {{20}} \
 7.     --db-subnet-group {{mydbsubnetgroup}} \
 8.     --master-username {{myuser}} \
 9.     --master-user-password {{mypassword}} \
10.     --backup-retention-period {{3}} \
11.     --no-multi-az \
12.     --port {{8200}} \
13.     --kms-key-id {{mykmskey}} \
14.     --custom-iam-instance-profile {{AWSRDSCustomInstanceProfileForRdsCustomInstance}}
```
在 Windows 中：  

```
 1. aws rds create-db-instance ^
 2.     --engine {{custom-sqlserver-ee}} ^
 3.     --engine-version {{15.00.4073.23.v1}} ^
 4.     --db-instance-identifier {{my-custom-instance}} ^
 5.     --db-instance-class {{db.m5.xlarge}} ^
 6.     --allocated-storage {{20}} ^
 7.     --db-subnet-group {{mydbsubnetgroup}} ^
 8.     --master-username {{myuser}} ^
 9.     --master-user-password {{mypassword}} ^
10.     --backup-retention-period {{3}} ^
11.     --no-multi-az ^
12.     --port {{8200}} ^
13.     --kms-key-id {{mykmskey}} ^
14.     --custom-iam-instance-profile {{AWSRDSCustomInstanceProfileForRdsCustomInstance}}
```
指定此處所顯示提示以外的密碼，作為安全最佳實務。

使用 `describe-db-instances` 命令取得執行個體的詳細資訊。

```
1. aws rds describe-db-instances --db-instance-identifier my-custom-instance
```

下列部分輸出顯示引擎、參數群組及其他資訊。

```
 1. {
 2.     "DBInstances": [
 3.         {
 4.             "PendingModifiedValues": {},
 5.             "Engine": "custom-sqlserver-ee",
 6.             "MultiAZ": false,
 7.             "DBSecurityGroups": [],
 8.             "DBParameterGroups": [
 9.                 {
10.                     "DBParameterGroupName": "default.custom-sqlserver-ee-15",
11.                     "ParameterApplyStatus": "in-sync"
12.                 }
13.             ],
14.             "AutomationMode": "full",
15.             "DBInstanceIdentifier": "my-custom-instance",
16.             "TagList": []
17.         }
18.     ]
19. }
```