

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

# 建立 Babelfish for Aurora PostgreSQL DB 叢集
<a name="babelfish-create"></a>

Aurora PostgreSQL 13.4 版及更新版本支援 Babelfish for Aurora PostgreSQL。

您可以使用 AWS 管理主控台 或 AWS CLI 來建立具有 Babelfish 的 Aurora PostgreSQL 叢集。

**注意**  
在 Aurora PostgreSQL 叢集中，為 Babelfish 保留了 `babelfish_db` 資料庫名稱。若自行在 Babelfish for Aurora PostgreSQLh 上建立 "babelfish\$1db" 資料庫，可能會導致 Aurora 無法成功佈建 Babelfish。

## 主控台
<a name="babelfish-create-cluster.console"></a>

**使用執行 的 Babelfish 建立叢集 AWS 管理主控台**

1. 開啟 Amazon RDS 主控台 ([https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/))，然後選擇 **Create database** (建立資料庫)。  
![\[\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/bbf_create_cluster_1.png)

1. 針對 **Choose a database creation method** (選擇資料庫建立方法)，請執行下列其中一個動作：
   + 若要指定詳細的引擎選項，請選擇 **Standard create** (標準建立)。
   + 若要使用預先設定的選項來支援 Aurora 叢集的最佳實務，請選擇 **Easy create** (輕鬆建立)。

1. 針對**引擎類型**，請選擇 **Aurora (PostgreSQL 相容)**。

1. 針對 **Available versions** (可用的版本)，選擇一個 Aurora PostgreSQL 版本。若要取得最新的 Babelfish 功能，請選擇最新的 Aurora PostgreSQL 主要版本。Aurora PostgreSQL 13.4 及更高版本支援 Babelfish。  
![\[\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/bbf_create_cluster_3.png)

1. 針對 **Templates** (範本)，選擇您的使用案例適合的範本。

1. 針對 **DB cluster identifier** (資料庫叢集識別符)，輸入稍後可以在資料庫叢集清單中輕鬆找到的名稱。

1. 針對 **Master username** (主要使用者名稱)，輸入管理員使用者名稱。Aurora PostgreSQL 的預設值為 `postgres`。您可以接受預設名稱，或選擇不同的名稱。例如，若要遵循 SQL Server 資料庫上使用的命名慣例，您可以輸入 `sa` (系統管理員) 作為主要使用者名稱。

   如果現在不建立名為 `sa` 的使用者，稍後可以在您選擇的用戶端建立。建立使用者後，使用 `ALTER SERVER ROLE` 命令將其新增至叢集的 `sysadmin` 群組 (角色)。
**警告**  
主要使用者名稱必須始終使用小寫字元失敗，資料庫叢集無法透過 TDS 連接埠連接到 Babelfish。

1. 針對 **Master password** (主要密碼)，建立一個強式密碼並確認密碼。

1. 對於下來一直到 **Babelfish settings ** (Babelfish 設定) 區段為止的選項，指定資料庫叢集設定。如需每項設定的相關資訊，請參閱 [Aurora 資料庫叢集的設定](Aurora.CreateInstance.md#Aurora.CreateInstance.Settings)。

1. 若要啟用 Babelfish 功能，請選取 **Turn on Babelfish** (開啟 Babelfish) 方塊。  
![\[\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/bbf_create_cluster_5.png)

1. 針對 **DB cluster parameter group** (資料庫叢集參數群組)，請執行下列其中一個動作：
   + 選擇 **Create new** (新建)，以建立啟用 Babelfish 的新參數群組。
   + 選擇 **Choose existing** (選擇現有)，以使用現有的參數群組。如果您使用現有群組，請務必在建立叢集之前修改群組，並新增 Babelfish 參數的值。如需 Babelfish 參數的資訊，請參閱[Babelfish 的資料庫叢集參數群組設定](babelfish-configuration.md)。

     如果您使用現有群組，請在後面的方塊中提供群組名稱。

1. 針對 **Database migration modee** (資料庫遷移模式)，選擇下列其中一項：
   + **Single database** (單一資料庫)，以遷移單一 SQL Server 資料庫。

     在某些情況下，多個使用者資料庫可能一起遷移，而您的最終目標是完整遷移至沒有 Babelfish 的原生 Aurora PostgreSQL。如果最終的應用程式需要合併的結構描述 (單一`dbo` 結構描述)，請務必先將 SQL Server 資料庫合併為單一 SQL Server 資料庫。然後使用 **Single database** (單一資料庫) 模式來遷移至 Babelfish。
   + **Multiple databases** (多個資料庫)，以遷移多個 SQL Server 資料庫 (來自單一 SQL Server 安裝)。多資料庫模式不合併不是來自單一 SQL Server 安裝的多個資料庫。如需有關遷移多個資料庫的資訊，請參閱[搭配單一資料庫或多個資料庫來使用 Babelfish](babelfish-architecture.md#babelfish-single_vs_multi_db)。
**注意**  
從 Aurora PostgreSQL 第 16 版，預設會選擇**多個資料庫**作為資料庫遷移模式。  
![\[\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/bbf_create_cluster_6.png)

1. 針對 **Default collation locale** (預設定序地區設定)，輸入伺服器地區設定。預設值為 `en-US`。如需定序的詳細資訊，請參閱 [了解 Babelfish for Aurora PostgreSQL 中的定序](babelfish-collations.md)。

1. 針對 **Collation name** (定序名稱) 欄位，輸入預設定序。預設值為 `sql_latin1_general_cp1_ci_as`。如需詳細資訊，請參閱 [了解 Babelfish for Aurora PostgreSQL 中的定序](babelfish-collations.md)。

1. 針對 **Babelfish TDS 連接埠**，請輸入預設連接埠 `1433`。目前，Babelfish 僅支援您資料庫叢集的連接埠 `1433`。

1. 針對 **DB parameter group** (資料庫參數群組)，選擇參數群組，或讓 Aurora 使用預設設定為您建立新的群組。

1. 針對 **Failover priority** (容錯移轉優先順序)，選擇執行個體的容錯移轉優先順序。如果不選擇值，則預設為 `tier-1`。此優先順序決定從主要執行個體失敗中復原時提升複本所按照的順序。如需詳細資訊，請參閱[Aurora 資料庫叢集的容錯能力](Concepts.AuroraHighAvailability.md#Aurora.Managing.FaultTolerance)。

1. 針對 **Backup retention period** (備份保留期),選擇 Aurora 保留資料庫備份副本的時間長度 (1 到 35 天)。您可以使用備份副本對資料庫進行時間點復原 (PITR)，可精確至秒。預設保留期間為七天。  
![\[\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/bbf_create_cluster_7.png)

1. 選擇 **Copy tags to snapshots** (將標籤複製到快照)，在建立快照時將任何資料庫執行個體標籤複製到資料庫快照。
**注意**  
從快照還原資料庫叢集時，其不會還原為 Babelfish for Aurora PostgreSQL 資料庫叢集。您需要開啟資料庫叢集參數群組中控制 Babelfish 偏好設定的參數，才能再次啟用 Babelfish。如需 Babelfish 參數的詳細資訊，請參閱[Babelfish 的資料庫叢集參數群組設定](babelfish-configuration.md)。

1. 選擇 **Enable encryption** (啟用加密)，對此資料庫叢集啟用靜態加密 (Aurora 儲存加密)。

1. 選擇 **Enable Performance Insights** (啟用績效詳情)，以啟用 Amazon RDS 績效詳情。

1. 選擇 **Enable Enhanced monitoring** (啟用增強型監控)，以針對執行資料庫叢集的作業系統，開始即時收集指標。

1. 選擇 **PostgreSQL log** (PostgreSQL 日誌)，將日誌檔發佈到 Amazon CloudWatch Logs。

1. 選擇 **Enable auto minor version upgrade** (啟用自動次要版本升級)，在有次要版本升級可用時自動更新 Aurora 資料庫叢集。

1. 針對 **Maintenance window** (維護時段)，請執行下列動作：
   + 若要選擇 Amazon RDS 進行修改或執行維護的時間，請選擇 **Select window** (選取時段)。
   + 若要在非排定時間執行 Amazon RDS 維護，請選擇 **No preference** (無偏好設定)。

1. 選取 **Enable deletion protection** (啟用刪除保護) 方塊，以防止意外刪除您的資料庫。

   如果啟用此功能，則無法直接刪除資料庫。相反地，在刪除資料庫之後，您需要修改資料庫叢集並停用此功能。  
![\[\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/bbf_create_cluster_9.png)

1. 選擇**建立資料庫**。

你可以在 **Databases** (資料庫) 清單中看到為 Babelfish 建立的新資料庫。部署完成時，**Status** (狀態) 欄會顯示 **Available** (可用)。

![\[\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/bbf_create_cluster_10.png)


## AWS CLI
<a name="babelfish-create-cluster.CLI"></a>

當您使用 建立 Babelfish for Aurora PostgreSQL 時 AWS CLI，您需要傳遞命令資料庫叢集參數群組的名稱，以用於叢集。如需詳細資訊，請參閱[資料庫叢集先決條件](Aurora.CreateInstance.md#Aurora.CreateInstance.Prerequisites)。

使用 AWS CLI 建立具有 Babelfish 的 Aurora PostgreSQL 叢集之前，請執行下列動作：
+ 從 [Amazon Aurora 端點和配額](https://docs.aws.amazon.com/general/latest/gr/aurora.html)上的服務清單中，選擇您的端點 URL。
+ 建立叢集的參數群組。如需參數群組的詳細資訊，請參閱[Amazon Aurora 的參數群組](USER_WorkingWithParamGroups.md)。
+ 修改參數群組，新增參數來啟用 Babelfish。<a name="babelfish.CLI.Creating.DBCluster"></a>

**使用 建立具有 Babelfish 的 Aurora PostgreSQL 資料庫叢集 AWS CLI**

下列範例使用預設主要使用者名稱，`postgres`。根據需要取代成以您為資料庫叢集建立的使用者名稱，例如 `sa`，或者如果您不接受預設值，則取代成任何您選擇的使用者名稱。

1. 建立參數群組。

   對於 Linux、macOS 或 Unix：

   ```
   aws rds create-db-cluster-parameter-group \
   --endpoint-url endpoint-url \
   --db-cluster-parameter-group-name parameter-group \
   --db-parameter-group-family aurora-postgresql14 \
   --description "description"
   ```

   在 Windows 中：

   ```
   aws rds create-db-cluster-parameter-group ^
   --endpoint-url endpoint-URL ^
   --db-cluster-parameter-group-name parameter-group ^
   --db-parameter-group-family aurora-postgresql14 ^
   --description "description"
   ```

1. 修改參數群組來啟用 Babelfish。

   對於 Linux、macOS 或 Unix：

   ```
   aws rds modify-db-cluster-parameter-group \
   --endpoint-url endpoint-url \
   --db-cluster-parameter-group-name parameter-group \
   --parameters "ParameterName=rds.babelfish_status,ParameterValue=on,ApplyMethod=pending-reboot"
   ```

   在 Windows 中：

   ```
   aws rds modify-db-cluster-parameter-group ^
   --endpoint-url endpoint-url ^
   --db-cluster-parameter-group-name paramater-group ^
   --parameters "ParameterName=rds.babelfish_status,ParameterValue=on,ApplyMethod=pending-reboot"
   ```

1. 識別新資料庫叢集的資料庫子網路群組和 Virtual Private Cloud (VPC) 安全群組 ID，然後呼叫 [create-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-cluster.html) 命令。

   對於 Linux、macOS 或 Unix：

   ```
   aws rds create-db-cluster \
   --db-cluster-identifier  cluster-name\
   --master-username postgres \
   --manage-master-user-password \
   --engine aurora-postgresql \
   --engine-version 14.3            \
   --vpc-security-group-ids security-group \
   --db-subnet-group-name subnet-group-name \
   --db-cluster-parameter-group-name parameter-group
   ```

   在 Windows 中：

   ```
   aws rds create-db-cluster ^
   --db-cluster-identifier cluster-name ^
   --master-username postgres ^
   --manage-master-user-password ^
   --engine aurora-postgresql ^
   --engine-version 14.3 ^
   --vpc-security-group-ids security-group ^
   --db-subnet-group-name subnet-group ^
   --db-cluster-parameter-group-name parameter-group
   ```

   此範例會指定 `--manage-master-user-password` 選項來產生主要使用者密碼，並在 Secrets Manager 中管理該密碼。如需詳細資訊，請參閱[使用 Amazon Aurora 和 進行密碼管理 AWS Secrets Manager](rds-secrets-manager.md)。或者，您可以使用 `--master-password` 選項，自行指定和管理密碼。

1. 明確為資料庫叢集建立主要執行個體。當您呼叫 [create-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-instance.html) 命令時，使用您在步驟 3 中為 `--db-cluster-identifier` 引數建立的叢集名稱，如下所示。

   對於 Linux、macOS 或 Unix：

   ```
   aws rds create-db-instance \
   --db-instance-identifier instance-name \
   --db-instance-class db.r6g \
   --db-subnet-group-name subnet-group \
   --db-cluster-identifier cluster-name \
   --engine aurora-postgresql
   ```

   在 Windows 中：

   ```
   aws rds create-db-instance ^
   --db-instance-identifier instance-name ^
   --db-instance-class db.r6g ^
   --db-subnet-group-name subnet-group ^
   --db-cluster-identifier cluster-name ^
   --engine aurora-postgresql
   ```