Advanced goldengate training ⅰ

26
Advanced Goldengate Training www.oggers.net 2011-07-25

description

oracle goldengate training

Transcript of Advanced goldengate training ⅰ

Page 1: Advanced goldengate training ⅰ

Advanced Goldengate Training Ⅰ

www.oggers.net 2011-07-25

Page 2: Advanced goldengate training ⅰ

Agenda

□ Mothod of initialize data

□ Handing essential DML and DML error

□ Handing Advanced DDL sync and DDL error

□ Map and manipulating data

□ Monitor and Troubleshooting

Page 3: Advanced goldengate training ⅰ

Initialize Data

If your database is huge and application transcations are still ongoing ,there is little stop-time,How should you Initialize your data?

□ Use Keys + Handlecollsions

□ Use the commit SCN

Page 4: Advanced goldengate training ⅰ

Handlecollsions

□ How does the Handlecollsions work?

□ Where is the drawbacks with Handlecollsions?

● Does your tables have any primary key or unique key? ● Is there primary key update during initialization ?

Suitable for your environment ?

Page 5: Advanced goldengate training ⅰ

Commit SCN

♦ Commit SCN/Goldengate CSN

♦ the common initialized mothods Via SCN □ exp/imp □ expdp/impdp □ Transport Tablespace with Backupset (compare Transport Tablespace) □ Datagurd/RMAN □ Other consistent read utility

Page 6: Advanced goldengate training ⅰ

How to re-initialize a special table

□ split replicat group and merge it

□ Using transaction CSN Filter

map hr.job, target hr.job, filter (@GETENV ("transaction", "csn") > xxx);

Page 7: Advanced goldengate training ⅰ

Agenda

□ Mothod of initialize data

□ Handing essential DML and DML error

□ Handing Advanced DDL sync and DDL error

□ Map and manipulating data

□ Monitor and Troubleshooting

Page 8: Advanced goldengate training ⅰ

Non-supported data types

● ANYDATA● ANYDATASET● ANYTYPE● BFILE● BINARY_INTEGER● MLSLABEL● PLS_INTEGER● TIMEZONE_ABBR● TIMEZONE_REGION● URITYPE● UROWID

Page 9: Advanced goldengate training ⅰ

DML replication action

□ Keys(Primary key/unique key/keycols) action ● why to recommend to use keys? ● How to use keycols?

□ supplemental non-key column action

Page 10: Advanced goldengate training ⅰ

Handing DML error

□ Handing replicat errors on DML operations via REPERROR

Abort : roll back the transaction and stop processing

Discard: log the error to the discard file and continue processing

Exception: send the error for exceptions processing

Ignore: ignore the error and continue processing

example: reperror default,discard discardfile ./dirrpt/rep_hr.dsc,append,megabytes 100

Page 11: Advanced goldengate training ⅰ

Use multiple REPERROR statements

□ handing special error-code

reperror XXXX discard

□ handing special object

reperror default ignore exclude/include objname “hr.jobs”

Page 12: Advanced goldengate training ⅰ

REPERROR (DEFAULT, EXCEPTION)MAP hr.jobs, TARGET hr.jobs, &COLMAP (USEDEFAULTS);MAP hr.jobs, TARGET hr.jobs_exception, &EXCEPTIONSONLY, &INSERTALLRECORDS &COLMAP (USEDEFAULTS, &DML_DATE = @DATENOW(), &OPTYPE = @GETENV("LASTERR", "OPTYPE"), &ERR_NUM = @GETENV("LASTERR", "DBERRNUM"), &ERR_MSG = @GETENV("LASTERR", "DBERRMSG"));

Use exception table

Page 13: Advanced goldengate training ⅰ

Agenda

□ Mothod of initialize data

□ Handing essential DML and DML error

□ Handing Advanced DDL sync and DDL error

□ Map and manipulating data

□ Monitor and Troubleshooting

Page 14: Advanced goldengate training ⅰ

DDL limitations and influence

□ Disable recycle bin and affect other database environment

□ affect data filtering, and manipulation by the data pump (passthru/nopassthru)

□ affect data-definition

□ Others

Must configure DDL synchronization?

Page 15: Advanced goldengate training ⅰ

DDL Scope

□ Mapped Objects that are specified in TABLE and MAP statements

□ Unmapped Objects that are not specified in TABLE and MAP statements

□ Other scope DDL operations that cannot be mapped are of OTHER scope,just like the follow operations: create user,grant role,create tablespace ,alter datafile …

Page 16: Advanced goldengate training ⅰ

● exclude/include ● mapped/unmapped/other/all filter scope● opttype/objtype/objname filter special ddl action and object● instr/instrwors filter via matching

DDL Filter

ddl &include mapped exclude objtype 'table‘ objname "hr.jobs", &exclude INSTRWORDS 'alter add “city"', &include unmapped, objname "hr3.jobs", &include other

Page 17: Advanced goldengate training ⅰ

● When may we use DDLSUBST like as the objects on source and target have the different tablespace like as the datafile on source and tarhet have different destination ---------

DDL DDLSUBST

DDLSUBST 'users' with 'system' include mapped objtype ‘table’ INSTRWORDS 'create table tablespace "users"'

Notice:1. Must be careful and the best way is to restrict the DDL statement via

DDL inclusion and exclusion options2. Take care of ddl matching via instr, it’s strict matching, including space

character, carriage-return character

Page 18: Advanced goldengate training ⅰ

derived object

□ Notice the derived object action● Rename● CTAS● Index● Trigger

□ mapderived/ nomapderived

Page 19: Advanced goldengate training ⅰ

DDL Other Topic

□ Sequence can the sequence really be synchronized before V11.1.1.1.0?

□ Password □ Add supplemental log groups ddloptions addtrandata retryop

Page 20: Advanced goldengate training ⅰ

Use multiple DDLERROR statements

□ handing special error-code

ddlerror XXXX discard

□ handing special object

ddlerror default ignore include OBJTYPE TABLE OBJNAME “hr1.*”

Page 21: Advanced goldengate training ⅰ

Agenda

□ Mothod of initialize data

□ Handing essential DML and DML error

□ Handing Advanced DDL sync and DDL error

□ Map and manipulating data

□ Monitor and Troubleshooting

Page 22: Advanced goldengate training ⅰ

Select Rows

□Method of select rows

● Filterselect rows based on a numeric value by using basic operators or one or more GoldenGate column-conversion functions

MAP hr.jobs,TARGET hr.jobs, FILTER (ON INSERT, job_id > 1000);

● Whereselect rows based on a conditional statement

MAP hr.jobs,TARGET hr.jobs, where (job_name =@presentand= “Jerry”);

Page 23: Advanced goldengate training ⅰ

Map Columns

□COLMAP

map table-level column

map hr.jobs, target hr.jobs_add,& colmap (usedefaults,totol_salary=salary*days);

□COLMATCH map between similarly structured tables that have different column names for the same sets of data

colmatch suffix _s map hr.jobs, target hr.jobs, colmap(usedefaults);

The column named Job_id on source is named Job_id_s on target

Page 24: Advanced goldengate training ⅰ

Data-definations file

□data-definations file It’s used to synchronize source and target tables that have dissimilar data definitions

● DEFGEN the tool is used to create a data-definations file

defgen paramfile dirprm/defgen.prm

● SOURCEDEFS Specifies a file that contains source data definitions created by the DEFGEN utility

Page 25: Advanced goldengate training ⅰ

Convert DML operations

□ select dml type

● GETUPDATES | IGNOREUPDATES ● GETDELETES | IGNOREDELETES ● GETINSERTS | IGNOREINSERTS

□ convert dml type

● INSERTALLRECORDS ● INSERTUPDATES ● INSERTDELETES ● UPDATEDELETES

Page 26: Advanced goldengate training ⅰ

Obtain transaction info

□ the useful of transaction info□ Function GETENV (“TRANSACTION”, “<return value>”) GETENV (“GGHEADER”, “<return value>”)

map hr.jobs, target hr.jobs,& colmap & ( & usedefaults,& Op_type = @GETENV (“GGHEADER”, “OPTYPE”),& Indicator = @GETENV (“GGHEADER”, “BEFOREAFTERINDICATOR”), & commit_ts = @GETENV (“GGHEADER”, “COMMITTIMESTAMP”) & )