GoldenGate将Oracle数据同步到GreenPlum(4)

--配置ffwriter.properties文件,模版可以从sample-dirprm中找到
 [gpadmin@mdw ogg]$ pwd
 /ggs/ogg
 [gpadmin@mdw ogg]$ cat ffwriter.properties
 #------------------------
 #LOGGING OPTIONS
 #------------------------
 goldengate.log.logname=ffwriter
 goldengate.log.level=DEBUG
 goldengate.log.modules=LOGMALLOC
 goldengate.log.level.LOGMALLOC=ERROR
 goldengate.log.tostdout=true
 goldengate.log.tofile=true
 #------------------------
 #FLAT FILE WRITER OPTIONS
 #------------------------
 goldengate.flatfilewriter.writers=dsvwriter
 goldengate.userexit.chkptprefix=ffwriter_
 #------------------------
 # dsvwriter options
 #------------------------
 dsvwriter.mode=DSV
 dsvwriter.rawchars=false
 dsvwriter.includebefores=false
 dsvwriter.includecolnames=false
 dsvwriter.omitvalues=false
 dsvwriter.diffsonly=false
 dsvwriter.omitplaceholders=false
 dsvwriter.files.onepertable=true
 #dsvwriter.files.prefix=csv
 dsvwriter.files.data.rootdir=./dirout
 dsvwriter.files.data.ext=_data.dsv
 dsvwriter.files.data.tmpext=_data.dsv.temp
 dsvwriter.files.data.rollover.time=10
 #dsvwriter.files.data.rollover.size=
 dsvwriter.files.data.norecords.timeout=10
 #dsvwriter.files.control.use=true
 #dsvwriter.files.control.ext=_data.control
 #dsvwriter.files.control.rootdir=./dirout
 dsvwriter.dsv.nullindicator.chars=
 dsvwriter.dsv.fielddelim.chars=|
 #dsvwriter.dsv.linedelim.chars=\n
 dsvwriter.dsv.quotes.chars="
 dsvwriter.dsv.quotes.escaped.chars=
 dsvwriter.metacols=opcode,timestamp
 dsvwriter.metacols.opcode.insert.chars=I
 dsvwriter.metacols.opcode.update.chars=U
 #dsvwriter.metacols.txind.fixedlen=1
 #dsvwriter.metacols.txind.begin.chars=B
 #dsvwriter.metacols.txind.middle.chars=M
 #dsvwriter.metacols.txind.end.chars=E
 dsvwriter.files.formatstring=pump_%s_%t_%d_%05n
 


--以下是ffwriter.properties模板文件
 
#------------------------
 #LOGGING OPTIONS
 #------------------------
 goldengate.log.logname=ffwriter
 goldengate.log.level=INFO
 goldengate.log.modules=LOGMALLOC
 goldengate.log.level.LOGMALLOC=ERROR
 goldengate.log.tostdout=false
 goldengate.log.tofile=true
 #------------------------
 #FLAT FILE WRITER OPTIONS
 #------------------------
 goldengate.flatfilewriter.writers=dsvwriter
 goldengate.userexit.chkptprefix=ffwriter_
 #------------------------
 # dsvwriter options
 #------------------------
 dsvwriter.mode=DSV
 dsvwriter.rawchars=false
 dsvwriter.includebefores=false
 dsvwriter.includecolnames=false
 dsvwriter.omitvalues=false
 dsvwriter.diffsonly=false
 dsvwriter.omitplaceholders=false
 #dsvwriter.files.onepertable=false
 dsvwriter.files.prefix=csv
 dsvwriter.files.data.rootdir=./dirout
 dsvwriter.files.data.ext=_data.dsv
 dsvwriter.files.data.tmpext=_data.dsv.temp
 dsvwriter.files.data.rollover.time=10
 #dsvwriter.files.data.rollover.size=
 dsvwriter.files.data.norecords.timeout=10
 dsvwriter.files.control.use=true
 dsvwriter.files.control.ext=_data.control
 dsvwriter.files.control.rootdir=./dirout
 dsvwriter.dsv.nullindicator.chars=<NULL>
 dsvwriter.dsv.fielddelim.chars=|
 dsvwriter.dsv.linedelim.chars=\n
 dsvwriter.dsv.quotes.chars="
 dsvwriter.dsv.quotes.escaped.chars=""
 dsvwriter.metacols=position,txind,opcode,timestamp,schema,table
 dsvwriter.metacols.txind.fixedlen=1
 dsvwriter.metacols.txind.begin.chars=B
 dsvwriter.metacols.txind.middle.chars=M
 dsvwriter.metacols.txind.end.chars=E
 dsvwriter.files.formatstring=pump_%s_%t_%d_%05n
 #------------------------
 # ldvwriter options
 #------------------------
 ldvwriter.mode=LDV
 ldvwriter.rawchars=true
 ldvwriter.includebefores=false
 ldvwriter.includecolnames=false
 ldvwriter.files.onepertable=false
 ldvwriter.files.data.rootdir=./dirout
 ldvwriter.files.data.ext=.data
 ldvwriter.files.data.tmpext=.temp
 ldvwriter.files.data.rollover.time=10
 ldvwriter.files.data.norecords.timeout=10
 ldvwriter.files.control.use=true
 ldvwriter.files.control.ext=.ctrl
 ldvwriter.files.control.rootdir=./dirout
 ldvwriter.metacols=position,timestamp,@TOKEN-RBA,@TOKEN-POS,opcode,txind,schema,table
 ldvwriter.metacols.TOKEN-RBA.fixedlen=10
 ldvwriter.metacols.TOKEN-POS.fixedlen=10
 ldvwriter.metacols.timestamp.fixedlen=26
 ldvwriter.metacols.schema.fixedjustify=right
 ldvwriter.metacols.schema.fixedpadchar.chars=Y
 ldvwriter.metacols.opcode.fixedlen=1
 ldvwriter.metacols.opcode.insert.chars=I
 ldvwriter.metacols.opcode.update.chars=U
 ldvwriter.metacols.opcode.delete.chars=D
 ldvwriter.metacols.txind.fixedlen=1
 ldvwriter.metacols.txind.begin.chars=B
 ldvwriter.metacols.txind.middle.chars=M
 ldvwriter.metacols.txind.end.chars=E
 ldvwriter.metacols.txind.whole.chars=W
 ldvwriter.ldv.vals.missing.chars=M
 ldvwriter.ldv.vals.present.chars=P
 ldvwriter.ldv.vals.null.chars=N
 ldvwriter.ldv.lengths.record.mode=binary
 ldvwriter.ldv.lengths.record.length=4
 ldvwriter.ldv.lengths.field.mode=binary
 ldvwriter.ldv.lengths.field.length=2
 ldvwriter.files.rolloveronshutdown=false
 ldvwriter.statistics.toreportfile=false
 ldvwriter.statistics.period=onrollover
 ldvwriter.statistics.tosummaryfile=true
 ldvwriter.statistics.overall=true
 ldvwriter.statistics.summary.fileformat=schema,table,schemaandtable,total,gctimestamp,ctimestamp
 ldvwriter.statistics.summary.delimiter.chars=|
 ldvwriter.statistics.summary.eol.chars=\n
 ldvwriter.metacols.position.format=dec
 ldvwriter.writebuffer.size=36863
 


--启动ffwriter
 GGSCI (mdw) 8> start ffwriter
 

Sending START request to MANAGER ...
 EXTRACT FFWRITER starting
 

GGSCI (mdw) 9> info all
 

Program    Status      Group      Lag          Time Since Chkpt
 

MANAGER    RUNNING                                         
 EXTRACT    RUNNING    FFWRITER    00:00:00      00:00:00   
 

GGSCI (mdw) 20> view report ffwriter
 

***********************************************************************
                  Oracle GoldenGate Capture for Oracle
                      Version 11.1.1.0.0 Build 078
    Linux, x64, 64bit (optimized), Oracle 11 on Jul 28 2010 14:58:37
 
 Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
 

Starting at 2014-02-16 00:03:46
 ***********************************************************************
 

Operating System Version:
 Linux
 Version #1 SMP Fri Jul 22 04:43:29 EDT 2011, Release 2.6.18-274.el5
 Node: mdw
 Machine: x86_64
                          soft limit  hard limit
 Address Space Size  :    unlimited    unlimited
 Heap Size            :    unlimited    unlimited
 File Size            :    unlimited    unlimited
 CPU Time            :    unlimited    unlimited
 

Process id: 16158
 

Description:
 

***********************************************************************
 **            Running with the following parameters                  **
 ***********************************************************************
 extract ffwriter
 CUSEREXIT ./flatfilewriter.so CUSEREXIT PASSTHRU INCLUDEUPDATEBEFORES, PARAMS "ffwriter.properties"
 /ggs/ogg/extract running with user exit library ./flatfilewriter.so, compatiblity level (2) is current.
 sourcedefs ./dirdef/scott.def
 table SCOTT.*;
 

CACHEMGR virtual memory values (may have been adjusted)
 CACHEBUFFERSIZE:                        64K
 CACHESIZE:                                4G
 CACHEBUFFERSIZE (soft max):              4M
 CACHEPAGEOUTSIZE (normal):                4M
 PROCESS VM AVAIL FROM OS (min):        4.15G
 CACHESIZEMAX (strict force to disk):  4.10G
 

***********************************************************************
 Started Oracle GoldenGate for Flat File
 Version 11.1.1.0.0
 ***********************************************************************
 

***********************************************************************
 **                    Run Time Messages                            **
 ***********************************************************************
 

Opened trail file ./dirdat/eb000000 at 2014-02-16 00:03:47
 

======================================================
 源端测试
 

[oracle@vzwc1 ~]$ sqlplus scott
 

SQL*Plus: Release 11.2.0.4.0 Production on Sun Feb 16 00:06:30 2014
 

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

Enter password:
 

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

SQL> delete from emp where rownum=1;
 

1 row deleted.
 

SQL> commit;
 

Commit complete.
 

SQL> update emp set ename='ZhongWC' where empno='7839';
 

1 row updated.
 

SQL> commit;
 

Commit complete.

======================================================
 查看目标端/ggs/ogg/dirout生成的FlatFile
 

[gpadmin@mdw dirout]$ pwd
 /ggs/ogg/dirout
 [gpadmin@mdw dirout]$ ll
 total 12
 -rw-rw-rw- 1 gpadmin gpadmin  45 Feb 16 00:06 pump_SCOTT_EMP_2014-02-16_00-06-44_00000_data.dsv
 -rw-rw-rw- 1 gpadmin gpadmin  95 Feb 16 00:09 pump_SCOTT_EMP_2014-02-16_00-09-42_00001_data.dsv
 -rw-rw-rw- 1 gpadmin gpadmin 118 Feb 16 00:09 SCOTT.EMPcontrol
 [gpadmin@mdw dirout]$ cat pump_SCOTT_EMP_2014-02-16_00-09-42_00001_data.dsv
 "U"|"2014-02-16 00:09:36.962844"|7839|"ZhongWC"|"PRESIDENT"||"1981-11-17:00:00:00"|5000.00||10
 [gpadmin@mdw dirout]$ cat pump_SCOTT_EMP_2014-02-16_00-06-44_00000_data.dsv
 
"D"|"2014-02-16 00:06:38.982882"|7369|||||||
 

GoldenGate没有直接针对GreenPlum数据库进行数据加载的接口,可以使用GoldenGate for FlatFile插件从oracle中抽取变化数据形成GreenPlum可以加载的文本,使用psql的copy命令或者gpload工具将变化数据加载到GreenPlum里。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d9d4d37846b4bc0ce68ed37f4a951f4a.html