Post on 14-Jun-2015
description
Advanced Goldengate Training Ⅰ
www.oggers.net 2011-07-25
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
Ⅰ
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
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 ?
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
□
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);
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
Ⅰ
Non-supported data types
● ANYDATA● ANYDATASET● ANYTYPE● BFILE● BINARY_INTEGER● MLSLABEL● PLS_INTEGER● TIMEZONE_ABBR● TIMEZONE_REGION● URITYPE● UROWID
Ⅰ
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
Ⅰ
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
Ⅰ
Use multiple REPERROR statements
□ handing special error-code
reperror XXXX discard
□ handing special object
reperror default ignore exclude/include objname “hr.jobs”
Ⅰ
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
Ⅰ
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
Ⅰ
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?
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 …
Ⅰ
● 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
● 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
derived object
Ⅰ
□ Notice the derived object action● Rename● CTAS● Index● Trigger
□ mapderived/ nomapderived
DDL Other Topic
Ⅰ
□ Sequence can the sequence really be synchronized before V11.1.1.1.0?
□ Password □ Add supplemental log groups ddloptions addtrandata retryop
Use multiple DDLERROR statements
□ handing special error-code
ddlerror XXXX discard
□ handing special object
ddlerror default ignore include OBJTYPE TABLE OBJNAME “hr1.*”
Ⅰ
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
Ⅰ
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”);
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
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
Convert DML operations
Ⅰ
□ select dml type
● GETUPDATES | IGNOREUPDATES ● GETDELETES | IGNOREDELETES ● GETINSERTS | IGNOREINSERTS
□ convert dml type
● INSERTALLRECORDS ● INSERTUPDATES ● INSERTDELETES ● UPDATEDELETES
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”) & )