

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

# 建立 CEV
<a name="custom-cev.create"></a>

您可以使用 AWS 管理主控台 或 AWS CLI 建立 CEV。指定多租戶或非多租戶架構。如需更多詳細資訊，請參閱 [多租戶架構考量](custom-creating.md#custom-creating.overview)。

一般而言，建立 CEV 大約需要兩個小時。在建立 CEV 之後，您可以使用它來建立或更新 RDS Custom 資料庫執行個體。如需詳細資訊，請參閱[建立 RDS Custom for Oracle 資料庫執行個體](custom-creating.md#custom-creating.create)及[升級 RDS Custom for Oracle 資料庫執行個體](custom-upgrading-modify.md)。

**注意**  
如果您的資料庫執行個體目前使用 Oracle Linux 7.9，請建立使用最新 AMI 的新 CEV，這會使用 Oracle Linux 8。然後修改執行個體以使用新的 CEV。

請注意建立 CEV 的下列要求和限制：
+ 包含您的安裝檔案的 Amazon S3 儲存貯體必須位於與您的 CEV 相同的 AWS 區域 中。否則，建立程序會失敗。
+ CEV 名稱的格式必須是 `major-engine-version.customized_string`，如 `19.cdb_cev1` 中所示。
+ CEV 名稱必須包含 1 到 50 個英數字元、底線、破折號或句點。
+ CEV 名稱不能包含連續的句點，如 `19..cdb_cev1` 中所示。

## 主控台
<a name="custom-cev.create.console"></a>

**若要建立 CEV**

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

1. 在導覽窗格中，選擇 **Custom engine versions** (自訂引擎版本)。

   **Custom engine versions** (自訂引擎版本) 頁面會顯示目前存在的所有 CEV。如果您尚未建立任何 CEV，則頁面為空白。

1. 選擇 **Create custom engine version** (建立自訂引擎版本)。

1. 在**引擎選項**中，執行下列動作：

   1. 針對 **Engine type** (引擎類型)，請選擇 **Oracle**。

   1. 對於**架構設定**，選擇性地選擇**多租用戶架構**以建立 Oracle 多租用戶 CEV，這會使用資料庫引擎 `custom-oracle-ee-cdb` 或 `custom-oracle-se2-cdb`。您只能使用多租戶 CEV 建立 RDS Custom for Oracle CDB。如果未選擇此選項，您的 CEV 是使用引擎 `custom-oracle-ee` 或 `custom-oracle-se2` 的非 CDB。
**注意**  
您選擇的架構是 CEV 的永久特性。您無法將 CEV 修改為稍後使用不同的架構。

   1. 請選擇下列其中一個選項：
      + **建立新 CEV** - 從頭開始建立 CEV。在此情況下，您必須指定 JSON 清單檔案，其會指定資料庫二進位檔案。
      + **從來源建立 CEV** - 在**指定要複製的 CEV** 中，選擇要用作來源 CEV 的現有 CEV。在此情況下，您可以指定新的 Amazon Machine Image (AMI)，但無法指定不同的資料庫二進位檔案。

   1. 在**引擎版本**中，選擇主要引擎版本。

1. 在**版本詳細資訊**中，執行下列動作：

   1. 在**自訂引擎版本名稱**中輸入有效名稱。例如，您輸入名稱 **19.cdb\$1cev1**。

   1. (選用) 輸入 CEV 的描述。

1. 在**安裝媒體**中，執行下列動作：

   1. (選用) 針對 **AMI ID**，將欄位保留空白以使用最新服務提供的 AMI，或輸入您先前用來建立 CEV 的 AMI。若要取得有效的 AMI ID，請使用下列任一技巧：
      + 在主控台中，選擇左側導覽窗格中的**自訂引擎版本**，然後選擇 CEV 的名稱。CEV 使用的 AMI ID 會出現在**組態**索引標籤中。
      + 在 AWS CLI 中，使用 `describe-db-engine-versions` 命令。搜尋輸出找出 `ImageID`。

   1. 針對 **S3 location of manifest files (資訊清單檔案的 S3 位置)**，輸入您在 [步驟 3：將您的安裝檔案上傳到 Amazon S3](custom-cev.preparing.md#custom-cev.preparing.s3) 中指定之 Amazon S3 儲存貯體的位置。例如，​輸入 **s3://my-custom-installation-files/123456789012/cev1/**。
**注意**  
您在其中建立 CEV 的 AWS 區域必須位於與 S3 儲存貯體相同的區域中。

   1. (僅建立新的 CEV) 對於 **CEV 清單檔案**，輸入您已在 [建立 CEV 資訊清單](custom-cev.preparing.md#custom-cev.preparing.manifest.creating) 建立的 JSON 清單檔案。

1. 在 **KMS 金鑰**區段中，選取**輸入金鑰 ARN** 以列出可用的 AWS KMS 金鑰。然後從清單選取 KMS 金鑰。

   RDS Custom 需要 AWS KMS 金鑰。如需更多詳細資訊，請參閱 [步驟 1：建立或重複使用對稱加密 AWS KMS 金鑰](custom-setup-orcl.md#custom-setup-orcl.cmk)。

1. (選用) 選擇**新增標籤**，為 CEV 建立鍵值組。

1. 選擇 **Create custom engine version** (建立自訂引擎版本)。

   如果 JSON 清單檔案的格式無效，主控台會顯示**驗證 CEV 清單檔案時發生錯誤**。修正問題，然後重試。

**Custom engine versions** (自訂引擎版本) 頁面隨即出現。您的 CEV 會顯示狀態 **Creating (正在建立)**。建立 CEV 的程序大約需要兩個小時。

## AWS CLI
<a name="custom-cev.create.CEV"></a>

若要使用 AWS CLI 建立 CEV，請執行 [create-custom-db-engine-version](https://docs.aws.amazon.com/cli/latest/reference/rds/create-custom-db-engine-version.html) 命令。

下列選項是必要的：
+ `--engine` – 指定引擎類型。對於 CDB，指定 `custom-oracle-ee-cdb` 或 `custom-oracle-se2-cdb`。對於非 CDB，指定 `custom-oracle-ee` 或 `custom-oracle-se2`。您只能從使用 `custom-oracle-ee-cdb` 或 `custom-oracle-se2-cdb` 建立的 CEV 建立 CDB。您只能從使用 `custom-oracle-ee` 或 `custom-oracle-se2` 建立的 CEV 建立非 CDB。
+ `--engine-version` - 指定引擎版本。格式是 *major-engine-version*.*customized\$1string*。CEV 名稱必須包含 1 到 50 個英數字元、底線、破折號或句點。CEV 名稱不能包含連續的句點，如 `19..cdb_cev1` 中所示。
+ `--kms-key-id` – 指定 AWS KMS key。
+ `--manifest` – 指定 `manifest_json_string` 或 `--manifest file:file_name`。`manifest_json_string` 中不允許換行字元。請務必轉義 JSON 程式碼中的雙引號 (")，方法是在引號前加上反斜杠 (\$1)。

  下列範例為 19c 顯示了來自 [步驟 5：準備 CEV 清單檔案](custom-cev.preparing.md#custom-cev.preparing.manifest) 的 `manifest_json_string`。此範例會針對 Oracle 基本目錄、Oracle 主目錄，以及 UNIX/Linux 使用者和群組的識別符和名稱設定新值。如果您複製此字串，請在將其貼到命令之前移除所有換行字元。

  `"{\"mediaImportTemplateVersion\": \"2020-08-14\",\"databaseInstallationFileNames\": [\"V982063-01.zip\"],\"opatchFileNames\": [\"p6880880_190000_Linux-x86-64.zip\"],\"psuRuPatchFileNames\": [\"p32126828_190000_Linux-x86-64.zip\"],\"otherPatchFileNames\": [\"p29213893_1910000DBRU_Generic.zip\",\"p29782284_1910000DBRU_Generic.zip\",\"p28730253_190000_Linux-x86-64.zip\",\"p29374604_1910000DBRU_Linux-x86-64.zip\",\"p28852325_190000_Linux-x86-64.zip\",\"p29997937_190000_Linux-x86-64.zip\",\"p31335037_190000_Linux-x86-64.zip\",\"p31335142_190000_Generic.zip\"]\"installationParameters\":{ \"unixGroupName\":\"dba\", \ \"unixUname\":\"oracle\", \ \"oracleHome\":\"/home/oracle/oracle.19.0.0.0.ru-2020-04.rur-2020-04.r1.EE.1\", \ \"oracleBase\":\"/home/oracle/\"}}"`
+ `--database-installation-files-s3-bucket-name` - 指定您已在 [步驟 3：將您的安裝檔案上傳到 Amazon S3](custom-cev.preparing.md#custom-cev.preparing.s3) 中指定的相同儲存貯體名稱。您在其中執行 `create-custom-db-engine-version` 的 AWS 區域必須是與您的 Amazon S3 儲存貯體相同的區域。

您還可以指定下列選項：
+ `--description` - 指定 CEV 的描述。
+ `--database-installation-files-s3-prefix` - 指定您已在 [步驟 3：將您的安裝檔案上傳到 Amazon S3](custom-cev.preparing.md#custom-cev.preparing.s3) 中指定的資料夾名稱。
+ `--image-id` - 指定要重複使用的 AMI ID。若要尋找有效的 ID，請執行 `describe-db-engine-versions` 命令，然後搜尋輸出找出 `ImageID`。根據預設，RDS Custom for Oracle 會使用最新的可用 AMI。

下列範例會建立名為 `19.cdb_cev1` 的 Oracle 多租戶 CEV。此範例會重複使用現有的 AMI，而不是使用最新的可用 AMI。請確保 CEV 的名稱以主要引擎版本號為開頭。

**Example**  
對於 Linux、macOS 或 Unix：  

```
1. aws rds create-custom-db-engine-version \
2.     --engine custom-oracle-se2-cdb \
3.     --engine-version 19.cdb_cev1 \
4.     --database-installation-files-s3-bucket-name us-east-1-123456789012-custom-installation-files \
5.     --database-installation-files-s3-prefix 123456789012/cev1 \
6.     --kms-key-id my-kms-key \
7.     --description "test cev" \
8.     --manifest manifest_string \
9.     --image-id ami-012a345678901bcde
```
在 Windows 中：  

```
1. aws rds create-custom-db-engine-version ^
2.     --engine custom-oracle-se2-cdb ^
3.     --engine-version 19.cdb_cev1 ^
4.     --database-installation-files-s3-bucket-name us-east-1-123456789012-custom-installation-files ^
5.     --database-installation-files-s3-prefix 123456789012/cev1 ^
6.     --kms-key-id my-kms-key ^
7.     --description "test cev" ^
8.     --manifest manifest_string ^
9.     --image-id ami-012a345678901bcde
```

**Example**  
使用 `describe-db-engine-versions` 命令取得 CEV 的詳細資訊。  

```
1. aws rds describe-db-engine-versions \
2.     --engine custom-oracle-se2-cdb \
3.     --include-all
```
下列部分輸出顯示引擎、參數群組、清單檔案，以及其他資訊。  

```
 1. {
 2.     "DBEngineVersions": [
 3.         {
 4.             "Engine": "custom-oracle-se2-cdb",
 5.             "EngineVersion": "19.cdb_cev1",
 6.             "DBParameterGroupFamily": "custom-oracle-se2-cdb-19",
 7.             "DBEngineDescription": "Containerized Database for Oracle Custom SE2",
 8.             "DBEngineVersionDescription": "test cev",
 9.             "Image": {
10.                 "ImageId": "ami-012a345678901bcde",
11.                 "Status": "active"
12.             },
13.             "ValidUpgradeTarget": [],
14.             "SupportsLogExportsToCloudwatchLogs": false,
15.             "SupportsReadReplica": true,
16.             "SupportedFeatureNames": [],
17.             "Status": "available",
18.             "SupportsParallelQuery": false,
19.             "SupportsGlobalDatabases": false,
20.             "MajorEngineVersion": "19",
21.             "DatabaseInstallationFilesS3BucketName": "us-east-1-123456789012-custom-installation-files",
22.             "DatabaseInstallationFilesS3Prefix": "123456789012/cev1",
23.             "DBEngineVersionArn": "arn:aws:rds:us-east-1:123456789012:cev:custom-oracle-se2-cdb/19.cdb_cev1/abcd12e3-4f5g-67h8-i9j0-k1234l56m789",
24.             "KMSKeyId": "arn:aws:kms:us-east-1:732027699161:key/1ab2345c-6d78-9ef0-1gh2-3456i7j89k01",
25.             "CreateTime": "2023-03-07T19:47:58.131000+00:00",
26.             "TagList": [],
27.             "SupportsBabelfish": false,
28. ...
```

## 無法建立 CEV
<a name="custom-cev.create.failure"></a>

如果 CEV 建立的程序失敗，會發生 RDS Custom 問題 `RDS-EVENT-0198` 並且有訊息 `Creation failed for custom engine version major-engine-version.cev_name`，其中包含失敗的詳細資訊。例如，事件會列印遺失的檔案。

您無法修改失敗的 CEV。您只能刪除它，然後在修正失敗原因之後再試一次建立 CEV。如需有關 CEV 建立失敗原因進行疑難排解的詳細資訊，請參閱 [針對 RDS Custom for Oracle 的自訂引擎版本建立進行故障診斷](custom-troubleshooting.md#custom-troubleshooting.cev)。