## Context - setup extract/replicat for 3 tables: ORDERS, PRODUCTS and USERS - add 2 new tables TRANSACTIONS and TASKS to this extract/replica peer The aim is to minimize the downtime for the peer extract/replicat, so we will proceed in 2 steps: - create a second parallel extract/replicat for the 2 new tables - merge the second extract/replicat to initial extract/replicat ## Extract setup Add trandata to tables: dblogin useridalias YODA add trandata GREEN.ORDERS add trandata GREEN.PRODUCTS add trandata GREEN.USERS list tables GREEN.* Define params file for extract: edit params EXTRAA extract EXTRAA useridalias JEDIPRD sourcecatalog YODA exttrail ./dirdat/aa purgeoldextracts checkpointsecs 1 ddl include mapped warnlongtrans 1h, checkinterval 30m ------------------------------------ table GREEN.ORDERS; table GREEN.PRODUCTS; table GREEN.USERS; Add, register and start extract: dblogin useridalias JEDIPRD add extract EXTRAA, integrated tranlog, begin now add exttrail ./dirdat/aa, extract EXTRAA register extract EXTRAA, database container (YODA) start extract EXTRAA info extract EXTRAA detail ## Initial load Note down the current SCN on source database. SQL> select current_scn from v$database; CURRENT_SCN ----------- 10138382 On target DB create tables structure for ORDERS, PRODUCTS, USERS and do the inlitial load: SCN=10138382 impdp userid=admin/"Secret00!"@togoria/MAUL network_link=GREEN_AT_YODA logfile=MY:import_01.log remap_schema=GREEN:RED tables=GREEN.ORDERS,GREEN.PRODUCTS,GREEN.USERS TABLE_EXISTS_ACTION=TRUNCATE flashback_scn=$SCN ## Replicat setup Define params file for replicat. Take care to filter `filter(@GETENV ('TRANSACTION','CSN')`, it must be positionned to the SCN of initial load. edit params REPLAA replicat REPLAA useridalias MAUL dboptions enable_instantiation_filtering discardfile REPLAA.dsc, purge, megabytes 10 map YODA.GREEN.ORDERS, target MAUL.RED.ORDERS, filter(@GETENV ('TRANSACTION','CSN') > 10138382); map YODA.GREEN.PRODUCTS, target MAUL.RED.PRODUCTS, filter(@GETENV ('TRANSACTION','CSN') > 10138382); map YODA.GREEN.USERS, target MAUL.RED.USERS, filter(@GETENV ('TRANSACTION','CSN') > 10138382); Add and start replicat: add replicat REPLAA, integrated, exttrail ./dirdat/aa dblogin useridalias SITHPRD register replicat REPLAA database start replicat REPLAA info all Wait to catch the lag: lag replicat When done you can remove filter `filter(@GETENV ('TRANSACTION','CSN')` edit params REPLAA replicat REPLAA useridalias MAUL dboptions enable_instantiation_filtering discardfile REPLAA.dsc, purge, megabytes 10 map YODA.GREEN.ORDERS , target MAUL.RED.ORDERS ; map YODA.GREEN.PRODUCTS , target MAUL.RED.PRODUCTS ; map YODA.GREEN.USERS , target MAUL.RED.USERS ; restart replicat REPLAA ## Add 2 new tables to extract/replicat Add trandata to tables: dblogin useridalias YODA add trandata GREEN.TRANSACTIONS add trandata GREEN.TASKS list tables GREEN.* Create a second extract EXTRAB to manage the new tables. Define extract parameters: edit params EXTRAB extract EXTRAB useridalias JEDIPRD sourcecatalog YODA exttrail ./dirdat/ab purgeoldextracts checkpointsecs 1 ddl include mapped warnlongtrans 1h, checkinterval 30m table GREEN.TRANSACTIONS; table GREEN.TASKS; Add, register and start extract: dblogin useridalias JEDIPRD add extract EXTRAB, integrated tranlog, begin now add exttrail ./dirdat/ab, extract EXTRAB register extract EXTRAB, database container (YODA) start extract EXTRAB info extract EXTRAB detail ## Initial load for new tables Note down the current SCN on source database. SQL> select current_scn from v$database; CURRENT_SCN ----------- 10284191 On target DB create tables structure for TRANSACTIONS, TASKS and do the inlitial load: SCN=10284191 impdp userid=admin/"Secret00!"@togoria/MAUL network_link=GREEN_AT_YODA logfile=MY:import_02.log remap_schema=GREEN:RED tables=GREEN.TRANSACTIONS,GREEN.TASKS TABLE_EXISTS_ACTION=TRUNCATE flashback_scn=$SCN ## New replicat setup Define extract parameters. Pay attention to `filter(@GETENV ('TRANSACTION','CSN')` clause to be setup to SCN of intial datapump load. edit params REPLAB replicat REPLAB useridalias MAUL dboptions enable_instantiation_filtering discardfile REPLAB.dsc, purge, megabytes 10 map YODA.GREEN.TRANSACTIONS, target MAUL.RED.TRANSACTIONS, filter(@GETENV ('TRANSACTION','CSN') > 10284191); map YODA.GREEN.TASKS, target MAUL.RED.TASKS, filter(@GETENV ('TRANSACTION','CSN') > 10284191); Add and start new replicat: add replicat REPLAB, integrated, exttrail ./dirdat/ab dblogin useridalias SITHPRD register replicat REPLAB database start replicat REPLAB info all Check if new replicat is running and wait to lag 0. ## Integrate the 2 new tables to initial extract/replicat: EXTRAA/REPLAA Add new tables to initial extract for a **double run**: edit params EXTRAA extract EXTRAA useridalias JEDIPRD sourcecatalog YODA exttrail ./dirdat/aa purgeoldextracts checkpointsecs 1 ddl include mapped warnlongtrans 1h, checkinterval 30m table GREEN.ORDERS; table GREEN.PRODUCTS; table GREEN.USERS; table GREEN.TRANSACTIONS; table GREEN.TASKS; Restart extract EXTRAA: restart extract EXTRAA Stop extracts in this **strictly order**: - **first** extract: EXTRAA - **second** extract: EXTRAB > It is **mandatory** to stop extracts in this order. > **The applied SCN on first replicat tables must be less than the SCN on second replicat** in order to allow the first replicat to start at the last applied psition in the trail file. Like this, the first replicat must not be repositionned in the past. stop EXTRACT EXTRAA stop EXTRACT EXTRAB Now stop both replicat also: stop replicat REPLAA stop replicat REPLAB Note down the SCN for each extract and premare new params file for initial replicat. info extract EXTRAA detail info extract EXTRAB detail In my case: - EXTRAA: SCN=10358472 - EXTRAB: SCN=10358544 > The SCN of EXTRAB should be greater than the SCN of EXTRAA Update REPLAA replicat parameter file in accordance with the latest SCN applied on new tables (the SCN of EXTRAB): edit params REPLAA replicat REPLAA useridalias MAUL dboptions enable_instantiation_filtering discardfile REPLAA.dsc, purge, megabytes 10 map YODA.GREEN.ORDERS , target MAUL.RED.ORDERS ; map YODA.GREEN.PRODUCTS , target MAUL.RED.PRODUCTS ; map YODA.GREEN.USERS , target MAUL.RED.USERS ; map YODA.GREEN.TRANSACTIONS , target MAUL.RED.TRANSACTIONS, filter(@GETENV ('TRANSACTION','CSN') > 10358544); map YODA.GREEN.TASKS , target MAUL.RED.TASKS, filter(@GETENV ('TRANSACTION','CSN') > 10358544); Start first extract/replicat start extract EXTRAA start replicat REPLAA When the lag is zero you can remove filter `filter(@GETENV ('TRANSACTION','CSN')` edit params REPLAA replicat REPLAA useridalias MAUL dboptions enable_instantiation_filtering discardfile REPLAA.dsc, purge, megabytes 10 map YODA.GREEN.ORDERS , target MAUL.RED.ORDERS ; map YODA.GREEN.PRODUCTS , target MAUL.RED.PRODUCTS ; map YODA.GREEN.USERS , target MAUL.RED.USERS ; map YODA.GREEN.TRANSACTIONS , target MAUL.RED.TRANSACTIONS ; map YODA.GREEN.TASKS , target MAUL.RED.TASKS ; Restart first replicat: start replicat REPLAA Now all tables are integrated in first extract/replicat. ## Remove second extract/replicat dblogin useridalias JEDIPRD unregister extract EXTRAB database delete extract EXTRAB dblogin useridalias MAUL unregister replicat REPLAB database delete replicat REPLAB