作業 1:設定 Oracle GoldenGate 的來源和目標資料庫
應使用下列建議來設定來源和目標 Oracle GoldenGate 資料庫。
執行下列步驟以完成此任務:
-
步驟 1.1 - 資料庫組態
-
步驟 1.2 - 建立資料庫複製管理員使用者
-
步驟 1.3 - 建立資料庫服務
步驟 1.1 - 資料庫組態
應使用下列建議來設定來源和目標 Oracle GoldenGate 資料庫:
| 組態 | 範圍 | 範例 |
|---|---|---|
| 啟用存檔日誌模式 | 來源與目標 | SQL> ARCHIVE LOG LIST Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 110 Next log sequence to archive 113 Current log sequence 113 |
啟用 FORCE LOGGING |
來源與目標 | ALTER DATABASE FORCE LOGGING; |
ENABLE_GOLDENGATE_REPLICATION |
來源、目標及待命資料庫 | ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION=TRUE SCOPE=BOTH SID='*'; |
| 補充日誌記錄 | 來源 複寫回轉時,目標上需要 |
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA; |
| 新增複製物件的綱要或表格層次日誌記錄 | 來源 複寫回轉時,目標上需要 |
ADD SCHEMATRANDATA 或 ADD TRANDATA |
STREAMS_POOL_SIZE |
來源 複寫回轉時,目標上需要 |
例如,在包含 2 個 Extract 和 2 個整合式 Replicat 的資料庫中:
ALTER SYSTEM SET STREAMS_POOL_SIZE=5G SCOPE=BOTH SID='*'; |
如需準備 Oracle GoldenGate 資料庫的步驟,請參閱準備 Oracle GoldenGate 資料庫。
步驟 1.2 - 建立資料庫複製管理員使用者
來源和目標資料庫需要建立具備適當權限的 GoldenGate 管理員使用者,如下所示:
-
多租戶容器資料庫 (CDB):
-
來源資料庫 GoldenGate Extract 必須設定為使用 c## 連線至 root 容器資料庫中的使用者
-
目標資料庫,每個可插拔資料庫 (PDB) 都需要個別的 GoldenGate 管理員使用者。
-
如需在 Oracle Multitenant 資料庫中建立 GoldenGate 管理員的進一步詳細資訊,請參閱 Configuring Oracle GoldenGate in a Multitenant Container Database 。
-
-
若為非 CDB 資料庫,請參閱準備 Oracle 的資料庫使用者與權限
以來源資料庫系統上的 oracle 作業系統使用者身分,執行下列 SQL 指示來建立 Oracle GoldenGate 的資料庫使用者,並指派必要的權限:
[opc@exadb1_node1 ~]$ sudo su - oracle
[oracle@exadb1_node1 ~]$ source dbName.env
[oracle@exadb1_node1 ~]$ sqlplus / as sysdba
# Source CDB
SQL>
alter session set container=cdb$root;
create user c##ggadmin identified by "ggadmin_password" container=all default tablespace USERS temporary tablespace temp;
alter user c##ggadmin quota unlimited on users;
grant set container to c##ggadmin container=all;
grant alter system to c##ggadmin container=all;
grant create session to c##ggadmin container=all;
grant alter any table to c##ggadmin container=all;
grant resource to c##ggadmin container=all;
exec dbms_goldengate_auth.grant_admin_privilege('c##ggadmin',container=>'all');
# Source PDB
SQL>
alter session set container=pdbName;
create user ggadmin identified by "ggadmin_password" container=current;
grant create session to ggadmin container=current;
grant alter any table to ggadmin container=current;
grant resource to ggadmin container=current;
exec dbms_goldengate_auth.grant_admin_privilege('ggadmin');
以目標系統上的 oracle 作業系統使用者身分,執行下列 SQL 指示來建立 Oracle GoldenGate 的資料庫使用者,並指派必要的權限:
[opc@exadb2_node1 ~]$ sudo su - oracle
[oracle@exadb2_node1 ~]$ source dbName.env
[oracle@exadb2_node1 ~]$ sqlplus / as sysdba
# Target PDB
SQL>
alter session set container=pdbName;
create user ggadmin identified by "ggadmin_password" container=current;
grant alter system to ggadmin container=current;
grant create session to ggadmin container=current;
grant alter any table to ggadmin container=current;
grant resource to ggadmin container=current;
grant dv_goldengate_admin, dv_goldengate_redo_access to ggadmin container=current;
exec dbms_goldengate_auth.grant_admin_privilege('ggadmin');
步驟 1.3 - 建立資料庫服務
如果來源和目標資料庫在使用 Oracle Data Guard 的 Oracle RAC 叢集上執行建議的組態,則必須建立以角色為基礎的服務,讓 Extract 或 Replicat 處理作業能夠連線至正確的資料保全主要資料庫執行處理。
使用來源多用戶資料庫時,root 容器資料庫 (CDB) 與包含要複製之綱要的可插式資料庫 (PDB) 需要個別服務。如果是目標多雲端用戶資料庫,PDB 則需要單一服務。
作為主要資料庫系統上的 oracle 作業系統使用者,使用 dbaascli 來尋找 CDB 和 PDB 名稱,如下所示:
[opc@exadb1_node1 ~]$ sudo su - oracle
[oracle@exadb1_node1 ~]$ source dbName.env
[oracle@exadb1_node1 ~]$ dbaascli database getDetails
--dbname dbName |egrep 'dbName|pdbName'
"dbName" : "dbName",
"pdbName" : "pdbName",
主要和待命資料庫系統上的 oracle 作業系統使用者可以使用下列命令來建立及啟動 CDB 資料庫服務:
[opc@exadb1_node1 ~]$ sudo su - oracle
[oracle@exadb1_node1 ~]$ source dbName.env
[oracle@exadb1_node1 ~]$ srvctl add service -db $ORACLE_UNQNAME
-service dbName.ggoraclevcn.com -preferred ORACLE_SID1
-available ORACLE_SID2 -role PRIMARY
以主要和待命資料庫系統上的 oracle 作業系統使用者身分,使用下列命令建立及啟動 PDB 資料庫服務:
[oracle@exadb1_node1 ~]$ srvctl add service -db $ORACLE_UNQNAME
-service dbName.pdbName.ggoraclevcn.com -preferred ORACLE_SID1
-available ORACLE_SID2 -pdb pdbName -role PRIMARY
以主要和待命資料庫系統上的 oracle 作業系統使用者身分,啟動並驗證服務是否正在執行,如下所示:
[oracle@exadb1_node1 ~]$ srvctl start service -db $ORACLE_UNQNAME -role
[oracle@exadb1_node1 ~]$ srvctl status service -d $ORACLE_UNQNAME |grep goldengate
Service dbName.ggoraclevcn.com is running on instance(s) SID1
Service dbName.pdbName.ggoraclevcn.com is running on instance(s) SID1
注意:請重複來源和目標資料庫系統中的步驟 1.3。