Oracle 11g Golden Gate DDL单向同步实例演示

1.指定Source端数据库模式

GGSCI (ogg1) 19> edit params ./GLOBALS
ggschema ogg
   
GGSCI (ogg1) 23> stop mgr
Manager process is required by other GGS processes.
Are you sure you want to stop it (y/n)? y
Sending STOP request to MANAGER ...
Request processed.
Manager stopped.
   
GGSCI (ogg1) 24> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     STOPPED                                          
EXTRACT     RUNNING     EXT1        00:00:00      00:00:10   
EXTRACT     RUNNING     PUMP1       00:00:00      00:00:00

2 Source Database安装DDL支持

SQL> conn /as sysdba;
Connected.
   
SQL> !pwd
/u01/app/oracle/ogg

#######创建用于记录DDL信息的表

SQL> @marker_setup.sql
Marker setup script
You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter Oracle GoldenGate schema name:ogg
Marker setup table script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to OGG
   
MARKER TABLE
-------------------------------
OK
MARKER SEQUENCE
-------------------------------
OK
Script complete.

#######创建相应的存储过程和trigger

SQL> @ddl_setup
   
Oracle GoldenGate DDL Replication setup script
Verifying that current user has privileges to install DDL Replication...
You will be prompted for the name of a schema for the Oracle GoldenGate database objects.
NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.
NOTE: The schema must be created prior to running this script.
NOTE: Stop all DDL replication before starting this installation.
Enter Oracle GoldenGate schema name:ogg
Working, please wait ...
Spooling to file ddl_setup_spool.txt
Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...
Check complete.
   
Using OGG as a Oracle GoldenGate schema name.
Working, please wait ...
DDL replication setup script complete, running verification script...
Please enter the name of a schema for the GoldenGate database objects:
Setting schema name to OGG
   
CLEAR_TRACE STATUS:
   
Line/pos                           Error
--------------------------------------
No errors                                   No errors
   
CREATE_TRACE STATUS:
Line/pos                           Error
---------------------------------------- -
No errors                                   No errors
   
TRACE_PUT_LINE STATUS:
Line/pos                           Error
----------------------------------------
No errors                                   No errors
   
INITIAL_SETUP STATUS:
Line/pos                           Error
--------------------------------------
No errors                                   No errors
   
DDLVERSIONSPECIFIC PACKAGE STATUS:
Line/pos                           Error
----------------------------------------
No errors                                   No errors
   
DDLREPLICATION PACKAGE STATUS:
Line/pos                           Error
-----------------------------------
No errors                                   No errors
   
DDLREPLICATION PACKAGE BODY STATUS:
Line/pos                           Error
------------------------------------
No errors                                   No errors
   
DDL IGNORE TABLE
-----------------------------------
OK
   
DDL IGNORE LOG TABLE
-----------------------------------
OK
DDLAUX   PACKAGE STATUS:
   
Line/pos                           Error
----------------------------------------------------------------
No errors                                   No errors
   
DDLAUX PACKAGE BODY STATUS:
   
Line/pos                           Error
----------------------------------------
No errors                                   No errors
   
SYS.DDLCTXINFO   PACKAGE STATUS:
   
Line/pos                           Error
   
---------------------------------------- -----------------------------------------------------------------
   
No errors                                   No errors
   
    
   
SYS.DDLCTXINFO   PACKAGE BODY STATUS:
   
    
   
Line/pos                           Error
   
---------------------------------------- -
   
No errors                                   No errors
   
    
   
DDL HISTORY TABLE
   
-----------------------------------
   
OK
   
    
   
DDL HISTORY TABLE(1)
   
-----------------------------------
   
OK
   
    
   
DDL DUMP TABLES
   
-----------------------------------
   
OK
   
    
   
DDL DUMP COLUMNS
   
-----------------------------------
   
OK
   
    
   
DDL DUMP LOG GROUPS
   
-----------------------------------
   
OK
   
    
   
DDL DUMP PARTITIONS
   
-----------------------------------
   
OK
   
    
   
DDL DUMP PRIMARY KEYS
   
-----------------------------------
   
OK
   
    
   
DDL SEQUENCE
   
-----------------------------------
   
OK
   
    
   
GGS_TEMP_COLS
   
-----------------------------------
   
OK
   
    
   
GGS_TEMP_UK
   
-----------------------------------
   
OK
   
    
   
DDL TRIGGER CODE STATUS:
   
    
   
Line/pos                           Error
   
---------------------------------------- --
No errors                                   No errors
   
DDL TRIGGER INSTALL STATUS
-----------------------------------
OK
   
DDL TRIGGER RUNNING STATU
-------------------------------------------------
ENABLED
   
STAYMETADATA IN TRIGGER
--------------------------------------------------
OFF
   
    
   
DDL TRIGGER SQL TRACING
---------------------------------------------------
0
   
    
   
DDL TRIGGER TRACE LEVEL
----------------------------------------------------
0
   
LOCATION OF DDL TRACE FILE
   
---------------------------------------------------
/u01/app/oracle/diag/rdbms/ogg1/ogg1/trace/ggs_ddl_trace.log
   
Analyzing installation status...
   
   
STATUS OF DDL REPLICATION
----------------------------------------------------
SUCCESSFUL installation of DDL Replication software components
   
Script complete.

#######创建DDL同步需要的角色

SQL> @role_setup
   
GGS Role setup script
   
This script will drop and recreate the role GGS_GGSUSER_ROLE
   
To use a different role name, quit this script and then edit the params.sql script to change the gg_role parameter to the preferred name. (Do not run the script.)
   
    
   
You will be prompted for the name of a schema for the GoldenGate database objects.
   
NOTE: The schema must be created prior to running this script.
   
NOTE: Stop all DDL replication before starting this installation.
   
Enter GoldenGate schema name:ogg
   
Wrote file role_setup_set.txt
   
PL/SQL procedure successfully completed.
   
Role setup script complete
   
Grant this role to each user assigned to the Extract, GGSCI, and Manager processes, by using the following SQL command:
   
GRANT GGS_GGSUSER_ROLE TO <loggedUser>
   
where <loggedUser> is the user assigned to the GoldenGate processes.

#######启动ddl trigger

SQL> @ddl_enable.sql
Trigger altered.

#######优化ddl trigger性能

SQL> @ddl_pin ogg
   
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.

[oracle@ogg1 ogg]$ pwd
/u01/app/oracle/ogg
   
[oracle@ogg1 ogg]$ ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

#######关闭Manager进程

GGSCI (ogg1) 11> stop mgr      

3 修改Source Database参数

#######停止Extract进程

GGSCI (ogg1) 2> stop ext1
   
Sending STOP request to EXTRACT EXT1 ...
Request processed.
   
GGSCI (ogg1) 4> info all
   
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     STOPPED                                          
EXTRACT     STOPPED     EXT1        00:00:00      00:00:08   
EXTRACT     RUNNING     PUMP1       00:00:00      00:00:03

#######修改Extract参数

GGSCI (ogg1) 6> edit params ext1
   
extract ext1
dynamicresolution
setenv (NLS_.AL32UTF8)
userid ogg,password ogg
exttrail /u01/app/oracle/ogg/dirdat/et
ddl include all
ddloptions addtrandata, report
table askoracle.*;

ddl include all:启动ddl支持,并且包含所有的ddl操作

#######启动MGR & Extract进程

GSCI (ogg1) 11> start mgr
Manager started.
   
GGSCI (ogg1) 12> start ext1
Sending START request to MANAGER ...
EXTRACT EXT1 starting
   
GGSCI (ogg1) 14> info all
   
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                          
EXTRACT     RUNNING     EXT1        00:02:51      00:00:04   
EXTRACT     RUNNING     PUMP1       00:00:00      00:00:03

4 修改Target Database参数

#######停止MGR和REP1进程

GGSCI (ogg2) 3> stop mgr
   
Manager process is required by other GGS processes.
Are you sure you want to stop it (y/n)? y
Sending STOP request to MANAGER ...
Request processed.
Manager stopped.
   
GGSCI (ogg2) 4> stop rep1
Sending STOP request to REPLICAT REP1 ...
Request processed.
   
GGSCI (ogg2) 5> info all
   
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     STOPPED                                          
REPLICAT    STOPPED     REP1        00:00:00      00:00:04

#######修改Rep1参数

GGSCI (ogg2) 6> edit params rep1
   
replicat rep1
userid ogg,password ogg
assumetargetdefs
reperror default,discard
discardfile /u01/app/oracle/ogg/dirrpt/rep1.dsc,append,megabytes 50
dynamicresolution
ddloptions report
ddlerror default ignore retryop maxretries 3 retrydelay 5
ddlerror default discard
ddlerror default ignore retryop
map askoracle.*, target askoracle.*;

#######启动MGR进程

GGSCI (ogg2) 7> start mgr
Manager started.
   
GGSCI (ogg2) 8> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING                                          
REPLICAT    RUNNING     REP1        00:00:00      00:00:02

5 单向DDL同步测试

Source端:

SQL> show user;
USER is "ASKORACLE"
   
SQL> select table_name from user_tables;
   
TABLE_NAME
------------------------------
OGG_TEST
   
SQL> create table askoracle(id number(10),createdate date,name varchar2(100));
Table created.
   
SQL> insert into askoracle values (1,sysdate,'askoracle');
 1    row created.
   
SQL> commit;
Commit complete.

Target端:

SQL> show user;
USER is "ASKORACLE"
   
SQL> select table_name from user_tables;
   
TABLE_NAME
------------------------------
OGG_TEST
   
SQL> select table_name from user_tables;
   
TABLE_NAME
------------------------------
ASKORACLE
OGG_TEST
   
SQL> select * from askoracle;
   
         ID CREATEDAT NAME
---------------------------------
          1 07-JAN-14 askoracle
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,504评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,434评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,089评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,378评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,472评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,506评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,519评论 3 413
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,292评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,738评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,022评论 2 329
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,194评论 1 342
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,873评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,536评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,162评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,413评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,075评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,080评论 2 352

推荐阅读更多精彩内容