码迷,mamicode.com
首页 > 其他好文 > 详细

Using GoldenGate EVENTACTIONS to customize processing

时间:2015-03-11 11:01:05      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:goldengate   eventactions   

EVENTACTIONS 可以指定一些关键字来触发一些事件,关键字有:IGNORE, DISCARD, ABORT, STOP, SHELL, TRACE, LOG

For Example:
GGSCI (zbdba1) 6> view param ext1

EXTRACT EXT1
setenv ( NLS_LANG = AMERICAN_AMERICA.ZHS16GBK )
USERID ogg,PASSWORD ogg
DDL &
INCLUDE MAPPED OBJTYPE 'TABLE' &
INCLUDE MAPPED OBJTYPE 'IDNEX' &
INCLUDE MAPPED OBJTYPE 'SEQUENCE' &
INCLUDE MAPPED OBJTYPE 'VIEW' &
INCLUDE MAPPED OBJTYPE 'PROCEDURE' &
INCLUDE MAPPED OBJTYPE 'FUNCTION' &
INCLUDE MAPPED OBJTYPE 'PACKAGE' &
INCLUDE MAPPED OBJTYPE 'MATERIALIZED VIEW' &
EXCLUDE OPTYPE COMMENT
DDLOPTIONS ADDTRANDATA NOCROSSRENAME REPORT
REPORTCOUNT EVERY 1 MINUTES,RATE
DISCARDFILE ./dirrpt/EXTSA.DSC,APPEND,MEGABYTES 1024
THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 60000 IOLATENCY 60000
DBOPTIONS ALLOWUNUSEDCOLUMN
WARNLONGTRANS 2H,CHECKINTERVAL 3M
exttrail ./dirdat/sa
FETCHOPTIONS NOUSESNAPSHOT,FETCHPKUPDATECOLS,MISSINGROW REPORT
table zbdba.test;


GGSCI (zbdba1) 7> view param ext2

EXTRACT EXT2
passthru
RMTHOST 192.168.56.61,MGRPORT 7839,COMPRESS
RMTTRAIL ./dirdat/sa
table zbdba.test;


GGSCI (zbdba2) 6> view param rep1

REPLICAT rep1
ASSUMETARGETDEFS
USERID ogg, PASSWORD ogg
discardfile ./dirdat/rep1_discard.txt,append,megabytes 5
DDL INCLUDE MAPPED
DDLOPTIONS REPORT
--BATCHSQL
DBOPTIONS DEFERREFCONST
DBOPTIONS LOBWRITESIZE 102400
HANDLECOLLISIONS
DDLERROR DEFAULT DISCARD RETRYOP MAXRETRIES 5 RETRYDELAY 20
--grouptransops 1
--maxtransops 1
APPLYNOOPUPDATES
MAP zbdba.test, TARGET zbdba.test,FILTER (@STREQ (OWNER, "ZBDBA" )), EVENTACTIONS ( IGNORE TRANS , STOP, SHELL "/ogg/hello.sh" );
这里指定当test表中的owner字段为ZBDBA市,就忽略事务,停止replicat进程,执行shell脚本。


那么我们来测试一下:

Source:
SQL> insert into test(owner,table_name) values('ZBDBA','zbdba');

1 row created.

SQL> commit
  2  ;

Commit complete.


Target:
tail -100f ggserr.log
2015-03-09 22:51:01  INFO    OGG-00996  Oracle GoldenGate Delivery for Oracle, rep1.prm:  REPLICAT REP1 started.
2015-03-09 22:51:37  WARNING OGG-00869  Oracle GoldenGate Delivery for Oracle, rep1.prm:  No unique key is defined for table 'TEST'. All viable columns will be used to represent the key, but may not guarantee uniqueness.  KEYCOLS may be used to define the key.
2015-03-09 22:51:37  INFO    OGG-01286  Oracle GoldenGate Delivery for Oracle, rep1.prm:  Executing shell command '/ogg/hello.sh' due to SHELL event for target table ZBDBA.TEST in file /ogg/dirdat/sa000004, RBA 1314.
2015-03-09 22:51:37  INFO    OGG-01287  Oracle GoldenGate Delivery for Oracle, rep1.prm:  Successfully executed shell command '/ogg/hello.sh'.
2015-03-09 22:51:37  WARNING OGG-01283  Oracle GoldenGate Delivery for Oracle, rep1.prm:  Stopping process due to STOP event for target table ZBDBA.TEST in file /ogg/dirdat/sa000004, RBA 1314        STOP request pending end-of-transaction (1 records so far).
2015-03-09 22:51:37  INFO    OGG-00994  Oracle GoldenGate Delivery for Oracle, rep1.prm:  REPLICAT REP1 stopped normally.

发现进程停止并且执行脚本
查看进程:

GGSCI (zbdba2) 7> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                          
REPLICAT    STOPPED     REP1        00:00:06      00:07:59   
查看脚本:

[ogg@zbdba2 ogg]$ cat hello.sh
#!/bin/bash
touch zbdba.txt

[ogg@zbdba2 ogg]$ ll zbdba.txt
-rw-rw-rw- 1 ogg oinstall 0 Mar  9 22:51 zbdba.txt




Using GoldenGate EVENTACTIONS to customize processing

标签:goldengate   eventactions   

原文地址:http://blog.csdn.net/zbdba/article/details/44194257

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!