

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

# 使用 Oracle GoldenGate 從 Oracle 資料庫遷移至 Amazon RDS for PostgreSQL
<a name="migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate"></a>

*Dhairya Jindani、Sindhusha Paturu 和 Rajeshkumar Sabankar，Amazon Web Services*

## 總結
<a name="migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate-summary"></a>

此模式說明如何使用 Oracle Cloud Infrastructure (OCI) GoldenGate 將 Oracle 資料庫遷移至 PostgreSQL 的 Amazon Relational Database Service (Amazon RDS)。

透過使用 Oracle GoldenGate，您可以在來源資料庫與一或多個目的地資料庫之間複寫資料，並將停機時間降至最低。

**注意**  
來源 Oracle 資料庫可以是內部部署或 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體。使用內部部署複寫工具時，您可以使用類似的程序。

## 先決條件和限制
<a name="migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate-prereqs"></a>

**先決條件**
+ 作用中的 AWS 帳戶
+ Oracle GoldenGate 授權
+ 連接至 PostgreSQL 資料庫的 Java Database Connectivity (JDBC) 驅動程式
+ 在目標 Amazon RDS for PostgreSQL 資料庫上使用 [AWS 結構描述Schema Conversion Tool](https://aws.amazon.com/dms/schema-conversion-tool/)和資料表

**限制**
+ Oracle GoldenGate 只能複寫現有的資料表資料 （初始載入） 和持續變更 （變更資料擷取）

**產品版本**
+ Oracle Database Enterprise Edition 10g 或更新版本 
+ OracleGoldenGate12.2.0.1.1 for Oracle 或更新版本
+ 適用於 PostgreSQLor 較新版本的 OracleGoldenGate12.2.0.1.1

## Architecture
<a name="migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate-architecture"></a>

下圖顯示使用 Oracle GoldenGate 將 Oracle 資料庫遷移至 Amazon RDS for PostgreSQL 的範例工作流程：

![\[從內部部署 Oracle 資料庫到 Amazon RDS for PostgreSQL 的遷移工作流程。\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/images/pattern-img/384f0eaf-8582-474a-a7f4-ec1048a4feb3/images/de541887-0d5f-4a9a-b136-ce2599355cb8.png)


該圖顯示以下工作流程：

1. Oracle GoldenGate [擷取程序](https://docs.oracle.com/goldengate/c1230/gg-winux/GGCON/processes-and-terminology.htm#GUID-6419F3A9-71EC-4D14-9C41-3BAA1E3CA19C)會針對來源資料庫執行，以擷取資料。

1. Oracle GoldenGate [Replicat 程序](https://docs.oracle.com/goldengate/c1230/gg-winux/GGCON/processes-and-terminology.htm#GUID-5EF0326C-9058-4C40-8925-98A223388C95)會將擷取的資料交付至目標 Amazon RDS for PostgreSQL 資料庫。

## 工具
<a name="migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate-tools"></a>
+ [Oracle GoldenGate](https://www.oracle.com/integration/goldengate/#:~:text=OCI%20GoldenGate%20is%20a%20real,in%20the%20Oracle%20Cloud%20Infrastructure.) 可協助您在 Oracle Cloud Infrastructure 中設計、執行、協調和監控資料複寫和串流資料處理解決方案。
+ [適用於 PostgreSQL 的 Amazon Relational Database Service (Amazon RDS)](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html) 可協助您在 AWS 雲端中設定、操作和擴展 PostgreSQL 關聯式資料庫。

## 史詩
<a name="migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate-epics"></a>

### 下載並安裝 Oracle GoldenGate
<a name="download-and-install-oracle-goldengate"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 下載 Oracle GoldenGate。 | 下載下列版本的 Oracle GoldenGate：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate.html)若要下載軟體，請參閱 [Oracle 網站上的 Oracle GoldenGate Downloads](https://www.oracle.com/middleware/technologies/goldengate-downloads.html)。 | DBA | 
| 在來源 Oracle 資料庫伺服器上安裝 Oracle GoldenGate for Oracle。 | 如需說明，請參閱 [Oracle GoldenGate 文件](https://docs.oracle.com/goldengate/1212/gg-winux/GIORA/toc.htm)。 | DBA | 
| 在 Amazon EC2 執行個體上安裝 Oracle GoldenGate for PostgreSQL 資料庫。 | 如需說明，請參閱 [Oracle GoldenGate 文件](https://docs.oracle.com/goldengate/1212/gg-winux/GIORA/toc.htm)。 | DBA | 

### 在來源和目標資料庫上設定 Oracle GoldenGate
<a name="configure-oracle-goldengate-on-the-source-and-target-databases"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在來源資料庫上設定 Oracle GoldenGate for Oracle 資料庫。 | 如需說明，請參閱 [Oracle GoldenGate 文件](https://docs.oracle.com/goldengate/1212/gg-winux/GIORA/toc.htm)。請務必設定下列項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate.html) | DBA | 
| 在目標資料庫上設定 Oracle GoldenGate for PostgreSQL。 | 如需說明，請參閱 [Oracle 網站上的使用 Oracle GoldenGate for PostgreSQL 的第 VI 部分](https://docs.oracle.com/en/middleware/goldengate/core/19.1/gghdb/using-oracle-goldengate-postgresql.html)。請務必設定下列項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate.html) | DBA | 

### 設定資料擷取
<a name="configure-the-data-capture"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在來源資料庫中設定擷取程序。 | 在來源 Oracle 資料庫中，建立擷取檔案以擷取資料。如需說明，請參閱 Oracle 文件中的[新增 EXTRACT](https://docs.oracle.com/goldengate/1212/gg-winux/GWURF/ggsci_commands006.htm#GWURF122)。擷取檔案包含建立擷取參數檔案和追蹤檔案目錄。 | DBA | 
| 設定資料幫浦，將追蹤檔案從來源傳輸到目標資料庫。 | 遵循 Oracle 網站上的*資料庫公用程式* [PARFILE](https://docs.oracle.com/database/121/SUTIL/GUID-7A045C82-5993-44EB-AFAD-B7D39C34BCCD.htm#SUTIL859) 中的指示，建立 EXTRACT 參數檔案和線索檔案目錄。如需詳細資訊，請參閱 Oracle 網站上的 *Fusion Middleware Understanding Oracle GoldenGate* 中的[什麼是線索？](https://docs.oracle.com/goldengate/c1230/gg-winux/GGCON/processes-and-terminology.htm#GUID-88674F53-1E07-4C00-9868-598F82D7113C)。 | DBA | 
| 在 Amazon EC2 執行個體上設定複寫。 | 建立複寫參數檔案和追蹤檔案目錄。如需建立複寫參數檔案的詳細資訊，請參閱 Oracle 資料庫文件中的第 [3.5 節驗證參數檔案。](https://docs.oracle.com/en/middleware/goldengate/core/21.3/admin/using-oracle-goldengate-parameter-files.html#GUID-1E32A9AD-25DB-4243-93CD-E643E7116215)如需建立追蹤檔案目錄的詳細資訊，請參閱 Oracle Cloud 文件中的[建立追蹤](https://docs.oracle.com/en/cloud/paas/goldengate-cloud/gwuad/creating-trail.html)。請務必在目標的 GLOBALS 檔案中新增檢查點資料表項目。如需詳細資訊，請參閱 Oracle 網站上的 *Fusion Middleware Understanding Oracle GoldenGate* 中的[什麼是複本？](https://docs.oracle.com/goldengate/c1230/gg-winux/GGCON/processes-and-terminology.htm#GGCON-GUID-5EF0326C-9058-4C40-8925-98A223388C95)。 | DBA | 

### 設定資料複寫
<a name="configure-the-data-replication"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在來源資料庫中，建立參數檔案以擷取初始載入的資料。 | 遵循 Oracle Cloud 文件中[在 GGSCI 中建立參數檔案](https://docs.oracle.com/en/cloud/paas/goldengate-cloud/gwuad/using-oracle-goldengate-parameter-files.html#GUID-5C49C522-8B28-4E4B-908D-66A33717CE6C)的指示。確定 Manager 正在目標上執行。 | DBA | 
| 在目標資料庫中，建立參數檔案以複寫初始載入的資料。 | 遵循 Oracle Cloud 文件中[在 GGSCI 中建立參數檔案](https://docs.oracle.com/en/cloud/paas/goldengate-cloud/gwuad/using-oracle-goldengate-parameter-files.html#GUID-5C49C522-8B28-4E4B-908D-66A33717CE6C)的指示。請務必新增並啟動複寫程序。 | DBA | 

### 切換到 Amazon RDS for PostgreSQL 資料庫
<a name="cut-over-to-the-amazon-rds-for-postgresql-database"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 停止複寫程序，並確保來源和目標資料庫處於同步狀態。 | 比較來源和目標資料庫之間的資料列計數，以確保資料複寫成功。 | DBA | 
| 設定資料定義語言 (DDL) 支援。 | 執行 DDL 指令碼，以在 PostgreSQL 上建立觸發條件、序列、同義詞和參考金鑰。您可以使用任何標準 SQL 用戶端應用程式來連線至資料庫叢集中的資料庫。例如，您可以使用 [pgAdmin](https://www.pgadmin.org/) 連線到資料庫執行個體。 | DBA | 

## 相關資源
<a name="migrate-from-oracle-database-to-amazon-rds-for-postgresql-by-using-oracle-goldengate-resources"></a>
+ [Amazon RDS for PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html) (*Amazon RDS 使用者指南*)
+ [Amazon EC2 文件](https://docs.aws.amazon.com/ec2/)
+ [Oracle GoldenGate 支援的處理方法和資料庫](https://docs.oracle.com/goldengate/1212/gg-winux/GWUAD/wu_about_gg.htm#GWUAD112) (Oracle 文件）