OracleOGG_GoldenGate数据库配置DDL同步(案例)

2014-03-08 Created By
BaoXinjian

**一、摘要**


  1. 不支持以及简单支持之DDL类型

(1).
Oracle数据库保留的Schema,GoldenGate是匪支持之,如SYS、SYSTEM、PUBLIC等等

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

(3).
GoldenGate支持非跳高2M长度的DDL语句

(4).
GoldenGate只支持才为的DDL复制,不支持双向的DDL复制

(5).
GoldenGate只支持源端和对象端结构一直的

  1. 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参数

  1. 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语句

  1. DDL复制和DML复制的区别

(1). DDL复制是依据Trigger

(2). DML复制是基于日志

(3).
只是于主Extract进程中经过scn号安装有顺序进行组装,保证DDL操作以及DML操作以原来的次第之下你叫

  1. 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) ); 
  1. 目标端查看所创办的table是否有

    select * from dba_objects where object_name = ‘BXJ_OGG_DDL’;

  2. 倘若存在,测试成功

 

Thanks and Regards

相关文章