ITPub博客

首页 > Linux操作系统 > Linux操作系统 > goldengate的defgen

goldengate的defgen

Linux操作系统 作者:lovestanford 时间:2016-01-12 14:41:56 0 删除 编辑

 source/target表结构完全一致时,replicat声明assumetargetdefs即可,如果不一致,则需指定sourcedefs/targetdefs文件,其由 defgen生成;

 

什么时候使用defgen

跨数据库环境,例如从oraclemysql

2  source/target表定义不一致

Defgen可生成sourcedeftargetdef,前者用于target后者用于source

 

文件头包含metadata,文件体包含表信息

The file begins with a file header that shows the version of DEFGEN, information about character sets, the database type, the locale, and internal

metadata that indicates other data properties. Following the header are the tabledefinition sections.

Each table-definition section contains a table name, record length,number of columns, and one or more column definitions

详情可参照DataTypes From Defgen [ID 966190.1]

 

其生命周期如下

配置

Ggsci输入edit params defgen

--格式如下

CHARSET <character set> --DEFGEN读取文件时采用的字符集,默认为local OS字符集

DEFSFILE <full_pathname> [APPEND | PURGE] [CHARSET <character set>]  --指定data-def文件名,charset标注产生的def文件字符集,默认为local os字符集

[{SOURCEDB | TARGETDB} <dsn>] USERID <user>[, PASSWORD <password> [<encryption options>]]

TABLE <owner>.<table> [, {DEF | TARGETDEF} <template name>]; --指定候选表,而def/targetdef据此表产生def模板

 

运行

defgen paramfile dirprm/defgen.prm [reportfile dirrpt/defgen.rpt] [NOEXTATTR] [UPDATECS UTF-8]

默认DEFGEN使用本地localedef文件,可使用defgen修改def文件字符集

defgen paramfile ./dirdef/source.def UPDATECS UTF-8

 

传输

默认以ASCII模式FTPremote,如果def文件以 remote的字符集创建,则使用binary模式,避免出现不必要的换行;

 

1

创建多个source-def文件

DEFSFILE C:\ggs\dirdef\sales.def

USERID ogg, PASSWORD AACAAAAAAAAAAAJAUEUGODSCVGJEEIUGKJDJTFNDKEJFFFTC, &

AES128 KEYNAME mykey1

TABLE ord.*;

 

DEFSFILE C:\ggs\dirdef\admin.def

USERID ogg, PASSWORD AACAAAAAAAAAAAJAUEUGODSCVGJEEIUGKJDJTFNDKEJFFFTC, &

AES128 KEYNAME mykey1

TABLE hr.*;

 

REPLICAT acctrep

USERID ogg, PASSWORD AACAAAAAAAAAAAJAUEUGODSCVGJEEIUGKJDJTFNDKEJFFFTC, &

AES128 KEYNAME mykey1

SOURCEDEFS c:\ggs\dirdef\sales.def

MAP ord.*, TARGET ord.*;

SOURCEDEFS c:\ggs\dirdef\admin.def

MAP hr.*, TARGET hr.*;

 

 

Def模板

使用def模板

可被新表使用避免创建额外的def文件,新表必须有相同的表结构;

否则每次加入新表,必须为之创建def 文件,然后将内容复制到master def文件,最后重启进程

对于新增的表,无须重启进程或创建新的def文件

Def指定source-def模板

Targetdef指定target-def模板

 

When you create a definitions file, you can specify a definitions template that reduces the need to create new definitions files when tables are added to the Oracle GoldenGate

configuration after the initial startup.

To use a template, all of the new tables must have identical structures, such as in a customer database where there are separate but identical

tables for each customer (see “Rules for tables to be considered identical”).

If you do not use a template and new tables are added after startup, you must generate a definitions file for each new table that is added to the Oracle GoldenGate configuration,

then copy their contents to the existing master definitions file, and then restart the process.

http://docs.oracle.com/cd/E35209_01/doc.1121/e29397.pdf 

2

创建source def文件

DEFSFILE C:\ggs\dirdef\record.def --指定输出的def文件

USERID ogg, PASSWORD AACAAAAAAAAAAAJAUEUGODSCVGJEEIUGKJDJTFNDKEJFFFTC, &  --指定数据库连接信息

AES128 KEYNAME mykey1

TABLE acct.cust100, DEF custdef;  --依据acct.cust100创建template,供acct下同结构的表使用

TABLE ord.*;

TABLE hr.*;

 

 

replicat参数引用该文件

REPLICAT acctrep

USERID ogg, PASSWORD AACAAAAAAAAAAAJAUEUGODSCVGJEEIUGKJDJTFNDKEJFFFTC, &

AES128 KEYNAME mykey1

SOURCEDEFS c:\ggs\dirdef\record.def

MAP acct.cust*, TARGET acct.cust*, DEF custdef;

MAP ord.prod, TARGET ord.prod;

MAP ord.parts, TARGET ord.parts;

MAP hr.emp, TARGET hr.emp;

MAP hr.salary, TARGET hr.salary;

 

同时使用assumetargetdefs/sourcedefs

REPLICAT acctrep

USERID ogg, PASSWORD AACAAAAAAAAAAAJAUEUGODSCVGJEEIUGKJDJTFNDKEJFFFTC, &

AES128 KEYNAME mykey1

SOURCEDEFS c:\ggs\dirdef\record.def

MAP acct.cust*, TARGET acct.cust*, DEF custdef;

MAP ord.prod, TARGET ord.prod;

MAP ord.parts, TARGET ord.parts;

MAP hr.emp, TARGET hr.emp;

MAP hr.salary, TARGET hr.salary;

ASSUMETARGETDEFS

MAP rpt.stock, TARGET rpt.stock;

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/21754115/viewspace-1975316/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-09-27

  • 博文量
    213
  • 访问量
    973424