OGG_GoldenGate數據庫配置DDL同步(案例)

本文轉自:https://www.cnblogs.com/eastsea/p/4232300.html

一、摘要


1. 不支持和有限支持的DDL類型

(1). Oracle數據庫保留的Schema,GoldenGate是不支持的,如SYS、SYSTEM、PUBLIC等等

(2). GoldenGate10g DDL不支持Oracle回收站功能

(3). GoldenGate支持不超高2M長度的DDL語句

(4). GoldenGate只支持單向的DDL複製,不支持雙向的DDL複製

(5). GoldenGate只支持源端和目標端結構一直的

2. DDL處理方法

(1). 不支持DDL類型的處理方法

a. 不支持的Schema,OGG默認不復制,不許更多設定

b. 關閉Oracle回收站:alter system set recyclebin=off scope=both

(2). 受限支持DDL類型的處理費方法

a. 通過腳本ddl_ddl2file.sql獲取被忽略的Oracle DDL操作,將其獲取的操作放在USER_DUMP_DEST目錄一個文本文件中

b. 投遞過程中必須使用ASSUMETARGETDEFS參數

3. DDL複製的配置

(1). Oracle DDL複製的原理

(2). 安裝GoldenGate DDL對象

(3). 配置DDL支持

(4). DDL異常與錯誤處理

二、Oracle DDL複製的原理


1. DDL複製原理

基於數據庫全局Trigger的複製,在源數據建立一個Oracle全庫級別的Trigger捕捉DDL操作到中間表,Extract讀取中間表DDL語句並與DML語句根據csn排序,Pump投遞到目標端,目標端Replicat在重現該DDL語句

2. DDL複製和DML複製的區別

(1). DDL複製是基於Trigger

(2). DML複製是基於日誌

(3). 只是在主Extract進程中通過scn號安裝發生順序進行組裝,保證DDL操作和DML操作按照原來的順序之下你給

3. DDL複製和DML複製的關係

DDL複製和DML複製可以項目獨立,可以只啓動DDL複製,也可以只啓動DML複製,相互並不影響,他們之間只是在Extract進行組裝時根據scn號進行排序

 

三、安裝GoldenGate DDL對象


Step1. 停止Extract進程組

[ggate@gavinprod ~]$ cd $GGATE
[ggate@gavinprod ggate]$ ./ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

GGSCI (gavinprod.com) 1> stop E*
EXTRACT EXT1 is already stopped.
EXTRACT EXT2 is already stopped.

Step2. 指定源端數據庫的模式

GGSCI (gavinprod.com) 2> edit params ./GLOBALS
GGSCHEMA ggate

Step3. 停止Manager進程

GGSCI (gavinprod.com) 5> stop MGR !
Manager is already stopped.

Step4. 關閉Oracle的recyclebin

[oracle@gavinprod bin]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 30 22:50:10 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> show parameter recyclebin
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
recyclebin                           string      OFF

SQL> alter system set recyclebin = off scope = both;

Step5. 安裝DDL對象

[oracle@gavinprod ggate]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 30 22:54:49 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @/opt/oracle/ggate/marker_setup.sql

SQL> @/opt/oracle/ggate/ddl_setup.sql

SQL> @/opt/oracle/ggate/role_setup.sql

SQL> @/opt/oracle/ggate/ddl_enable.sql

Step6. 驗證DDL對象 

[oracle@gavinprod ggate]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 30 22:54:49 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> @/opt/oracle/ggate/marker_status.sql

四、配置DDL支持


Step1. 停止Extract 和 Replicat進程組

--Extract 端
GGSCI (gavinprod.com) 1> stop E*
EXTRACT EXT1 is already stopped.
EXTRACT EXT2 is already stopped.

GGSCI (gavinprod.com) 2> stop D*
EXTRACT DMP2 is already stopped.


--Replicat 端
GGSCI (odellprod.com) 1> stop R*
REPLICAT REP1 is already stopped.
REPLICAT REP2 is already stopped.

Step2. 修改Extract配置文件

GGSCI (gavinprod.com) 6> view params EXT2
extract ext2
userid ggate@gavinprod, password oracle
exttrail /opt/oracle/ggate/dirdat/ld

DDL INCLUDE ALL
DDLOPTIONS ADDTRANDATA, REPORT
table source_prod.*;

Step3. 修改Replicat配置文件

GGSCI (odellprod.com) 2> view params REP2

replicat rep2
ASSUMETARGETDEFS
userid ggate@odellprod,password oracle
discardfile /opt/oracle/ggate/dirdat/rep2_discard.txt, append, megabytes 10

DDL INCLUDE MAPPED
DDLOPTIONS REPORT
map source_prod.*, target target_prod.*;

Step4. 重啓進程

--Extract 端
GGSCI (gavinprod.com) 1> start E*
GGSCI (gavinprod.com) 2> start D*

--Replicat 端
GGSCI (odellprod.com) 1> start R*

Step5. 驗證結果

1. 目標端建立table bxj_ogg_ddl 

create table bxj_ogg_ddl (id number, name varchar2 (100) ); 

2. 目標端查看所創建的table是否存在

select * from dba_objects where object_name = 'BXJ_OGG_DDL';

3. 如果存在,測試成功

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章