Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

What is Data instantiation

Before data replication can start, the target database must have a copy of the database objects that are going to be replicated. It is also necessary that the data for the objects to be replicated are completely in sync at the point at which the replication starts. Replication can only keep data in sync from a certain point in time, all the data before that point in time must be replicated manually as a one off task.

This is done with the Oracle SCN. By using the Oracle SCN it is guaranteed that no transactions are lost during the replication setupcalled Data Instantiation and the Oracle SCN plays a key part in this

The Oracle SCN is captured at the point at which the replication starts to enable to pick a snapshot of the data at a point in time. This Oracle SCN is then used in two ways:

  1. Everything before the SCN must be copied manually. This is called the Data Instantiation and is done in this example through Oracle DataPump, but other methods are also available such as using a standby database.
  2. Everything after the SCN is replicated by the logical replication tool (in this case Dbvisit Replicate, but can also be Golden Gate)

Running DataPump

1. On the target server (dbv02), ensure that the OE schema is clean. Run the following drop script to ensure that there are no OE objects. If there are then the DataPump script will fail.

No Format
sqlplus oe/oeoe@ttorcl_trg
No Format
SQL> @/homeu01/oracle/swingbench/sql/soedgdrop2.sql
No Format
SQL> exit

 

2. On the target server (dbv02), setup the database link as user system.

No Format
sqlplus system/oracleoracle@ttorcl_trg
No Format
SQL> CREATE public DATABASE LINK ttorcl_src CONNECT TO system IDENTIFIED BY oracle USING 'ttorcl_src';
No Format
SQL> exit

 

This database link is needed for the Datapump script that is created as APPLY.sh. The content of datapump script APPLY.sh is similar to :the following. DO NOT COPY THE CONTENT. This is just an example. 

No Format
impdp SYSTEM/oracle@ttorcl_trg table_exists_action=TRUNCATE network_link=ttorcl_src directory=ttorcl_trg_DATA_PUMP_DIR flashback_scn=144157483046186 tables=OE.ADDRESSES,OE.CARD_DETAILS,OE.CMP3$95780,OE.CMP4$95780,OE.CUSTOMERS,OE.INVENTORIES,OE.LOGON,OE.ORDERENTRY_METADATA,OE.ORDERS,OE.ORDER_ITEMS,OE.PRODUCT_DESCRIPTIONS,OE.PRODUCT_INFORMATION,OE.PROMOTIONS,OE.WAREHOUSES   logfile=OE_WAREHOUSES.log JOB_NAME=DP_dbvrep_orcl_0001

The flashback_scn number (in this case 14415748case3046186) determines the consistency point as to where the data will be loaded to. All data prior to this SCN will be loaded using the above DataPump script. All data past this SCN will be replicated using Dbvisit Replicate. 

3. On the source server (dbv01) start the APPLY.sh script. This script will take approximately 5 - 25 minutes to complete.

No Format
$ cd ~oracle/dbvrep_orcl

a. Run the script

No Format
./APPLY.sh 

The output will be similar to:

No Format
Import: Release 1112.21.0.21.0 - Production on SatFri DecAug 281 1905:5531:2643 20132014
Copyright (c) 1982, 20092013, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g12c Enterprise Edition Release 1112.21.0.21.0 - 64bit Production
With the Partitioning, OLAP, DataAdvanced MiningAnalytics and Real Application Testing options
Starting "SYSTEM"."DP_DBVREP_ORCL_0001":  SYSTEM/********@ttorcl_trg table_exists_action=TRUNCATE network_link=ttorcl_src directory=ttorcl_trg_DATA_PUMP_DIR flashback_scn=144916713046186 tables=OE.ADDRESSES,OE.CARD_DETAILS,OE.CMP35780,OE.CMP45780,OE.CUSTOMERS,OE.INVENTORIES,OE.LOGON,OE.ORDERENTRY_METADATA,OE.ORDERS,OE.ORDER_ITEMS,OE.PRODUCT_DESCRIPTIONS,OE.PRODUCT_INFORMATION,OE.PROMOTIONS,OE.WAREHOUSES logfile=OE_WAREHOUSES.log JOB_NAME=DP_dbvrep_orcl_0001 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 1.008016 GB
Processing object type TABLE_EXPORT/TABLE/TABLE
Table "OE"."PROMOTIONS" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate
. . imported "OE"."ORDER_ITEMS"                         42900234291621 rows
. . imported "OE"."INVENTORIES"                          900632899846 rows
. . imported "OE"."ORDERS"                              14297901430027 rows
. . imported "OE"."ADDRESSES"                           15000001500112 rows
. . imported "OE"."CUSTOMERS"                           10000001000103 rows
. . imported "OE"."CARD_DETAILS"                        15000001500103 rows
. . imported "OE"."LOGON"                               23829842383613 rows
. . imported "OE"."PRODUCT_DESCRIPTIONS"                   1000 rows
. . imported "OE"."PRODUCT_INFORMATION"                    1000 rows
. . imported "OE"."ORDERENTRY_METADATA"                       4 rows
. . imported "OE"."WAREHOUSES"                             1000 rows
. . imported "OE"."PROMOTIONS"                                0 rows
Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/FUNCTIONAL_INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT/INDEX/STATISTICS/FUNCTIONAL_INDEX/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/INDEXCONSTRAINT/FUNCTIONAL_AND_BITMAP/INDEXREF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICSTABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Job "SYSTEM"."DP_DBVREP_ORCL_0001" successfully completed at 20:20:50
[oracle@source dbvrep_orcl]$
Note

During the import of the data, the archiver will may become stuck because there will may not be enough space.

Run the following script a few times on the target server (dbv02) to ensure that the flash recovery area does not fill up and pause the import:

No Format
/usr/local/bin/del_arch.sh orcl 0