Topics:
Parent topic: Using Oracle GoldenGate with DB2 LUW
To capture DML operations, Oracle GoldenGatereads the DB2 LUW online logs by default. However, it reads the archived logs if an online log is not available. To ensure the continuity and integrity of Oracle GoldenGateprocessing, configure the logs as follows.
Parent topic: Preparing the System for Oracle GoldenGate
Configure the database to retain the transaction logs for roll forward recovery by enabling one of the following parameter sets, depending on the database version.
DB2 LUW 9.5 and later:
Set the LOGARCHMETH
parameters as follows:
Set LOGARCHMETH1
to LOGRETAIN
.
Set LOGARCHMETH2
to OFF
.
Alternatively, you can use any other LOGARCHMETH
options, as long as forward recovery is enabled. For example, the following is valid:
Set LOGARCHMETH1
to DISK
.
Set LOGARCHMETH2
to TSM
.
To determine the log retention parameters:
Connect to the database.
db2 connect to database user username using password
Get the database name.
db2 list db directory
Get the database configuration for the database.
db2 get db cfg for database
The fields to view are:
Log retain for recovery status = RECOVERY User exit for logging status = YES
To set the log retention parameters:
Parent topic: Configuring the Transaction Logs for Oracle GoldenGate
Set the DB2 LUW OVERFLOWLOGPATH
parameter to the archive log directory. The node attaches automatically to the path variable that you specify.
db2 connect to database db2 update db cfg using overflowlogpath "path"
Exclude the node itself from the path. For example, if the full path to the archive log directory is /sdb2logarch/oltpods1/archive/OLTPODS1/NODE0000
, then the OVERFLOWLOGPATH
value should be specified as /sdb2logarch/oltpods1/archive/OLTPODS1.
Parent topic: Configuring the Transaction Logs for Oracle GoldenGate
The following table attributes must be addressed in an Oracle GoldenGate environment.
Parent topic: Preparing the System for Oracle GoldenGate
Disable triggers, cascade delete constraints, and cascade update constraints on the target tables, or alter them to ignore changes made by the Oracle GoldenGate database user. Oracle GoldenGate replicates DML that results from a trigger or cascade constraint. If the same trigger or constraint gets activated on the target table, it becomes redundant because of the replicated version, and the database returns an error. Consider the following example, where the source tables are emp_src
and salary_src
and the target tables are emp_targ
and salary_targ
.
A delete is issued for emp_src
.
It cascades a delete to salary_src
.
Oracle GoldenGate sends both deletes to the target.
The parent delete arrives first and is applied to emp_targ
.
The parent delete cascades a delete to salary_targ
.
The cascaded delete from salary_src
is applied to salary_targ
.
The row cannot be located because it was already deleted in step 5.
Parent topic: Preparing Tables for Processing
Oracle GoldenGate requires some form of unique row identifier on the source and target tables to locate the correct target rows for replicated updates and deletes.
Parent topic: Preparing Tables for Processing
Unless a KEYCOLS
clause is used in the TABLE
or MAP
statement, Oracle GoldenGate selects a row identifier to use in the following order of priority:
Primary key
First unique key alphanumerically that does not contain a timestamp or non-materialized computed column.
If none of the preceding key types exist (even though there might be other types of keys defined on the table) Oracle GoldenGate constructs a pseudo key of all columns that the database allows to be used in a unique key, excluding those that are not supported by Oracle GoldenGate in a key or those that are excluded from the Oracle GoldenGate configuration.
Note:
If there are other, non-usable keys on a table or if there are no keys at all on the table, Oracle GoldenGate logs an appropriate message to the report file. Constructing a key from all of the columns impedes the performance of Oracle GoldenGate on the source system. On the target, this key causes Replicat to use a larger, less efficient WHERE
clause.
Parent topic: Assigning Row Identifiers
KEYCOLS
to Specify a Custom KeyIf a table does not have one of the preceding types of row identifiers, or if you prefer those identifiers not to be used, you can define a substitute key if the table has columns that always contain unique values. You define this substitute key by including a KEYCOLS
clause within the Extract TABLE
parameter and the Replicat MAP
parameter. The specified key will override any existing primary or unique key that Oracle GoldenGate finds.
Parent topic: Assigning Row Identifiers
Do not add columns to a key after Oracle GoldenGate starts extracting data from the table. This rule applies to a primary key, a unique key, a KEYCOLS
key, or an all-column key. DB2 LUW does not supply a before image for columns that are added to a table. If any columns in a key are updated on the source, Oracle GoldenGate needs a before image to compare with the current values in the target table when it replicates the update.
Parent topic: Preparing Tables for Processing
Configure DB2 to log data changes in the expanded format that is supplied by the DATA CAPTURE CHANGES
feature of the CREATE TABLE
and ALTER TABLE
commands. This format provides Oracle GoldenGate with the entire before and after images of rows that are changed by update statements. You can use GGSCI to issue the ALTER TABLE
command as follows.
To Enable Change Capture from GGSCI:
Example 2-1 To Exclude LONGVAR
Logging:
To omit the INCLUDE LONGVAR COLUMNS
clause from the ALTER TABLE
command, use ADD TRANDATA
with the EXCLUDELONG
option.
ADD TRANDATA owner.table, EXCLUDELONG
Note:
If LONGVAR
columns are excluded from logging, the Oracle GoldenGate features that require before images, such as the GETUPDATEBEFORES
, NOCOMPRESSUPDATES
, and NOCOMPRESSDELETES
parameters, might return errors if tables contain those columns. For a workaround, see the REQUIRELONGDATACAPTURECHANGES
| NOREQUIRELONGDATACAPTURECHANGES
options of the TRANLOGOPTIONS
parameter.
Parent topic: Preparing Tables for Processing
To maintain parity between source and target materialized query tables (MQT), you replicate the base tables, but not the MQTs. The target database maintains the MQTs based on the changes that Replicat applies to the base tables.
The following are the rules for configuring these tables:
Include the base tables in your TABLE
and MAP
statements.
Do not include MQTs in the TABLE
and MAP
statements.
Wildcards can be used in TABLE
and MAP
statements, even though they might resolve MQT names along with regular table names. Oracle GoldenGate automatically excludes MQTs from wildcarded table lists. However, any MQT that is explicitly listed in an Extract TABLE
statement by name will cause Extract to abend.
Parent topic: Preparing Tables for Processing
To support the conversion of character sets between the source and target databases, make certain that the session character set is the same as the database character set. You can set the session character set with the DB2CODEPAGE
environment variable.
Parent topic: Preparing the System for Oracle GoldenGate
During the initialization of the Oracle GoldenGate environment, you will be doing an initial data synchronization and starting the Oracle GoldenGate processes for the first time. In conjunction with those procedures, you will be creating process groups. To create an Extract group, an initial start position must be established in the transaction log. This initial read position is on a transaction boundary that is based on one of the following:
End of the transaction file
A specific LSN value
The start point is specified with the BEGIN
option of the ADD EXTRACT
command.
When the Extract process starts for the first time, it captures all the transaction data that it encounters after the specified start point, but none of the data that occurred before that point. This can cause partial transactions to be captured if open transactions span the start point.
To ensure initial transactional consistency:
To avoid the capture of partial transactions, initialize the Extract process at a point in time when the database is in a paused state. DB2 LUW provides a QUIESCE
command for such a purpose. This is the only way to ensure transactional consistency.
Note:
After the Extract is past the initialization, subsequent restarts of the Extract do not extract partial transactions, because the process uses recovery checkpoints to mark its last read position.
To view open transactions:
IBM provides a utility called db2pd
for monitoring DB2 databases and instances. You can use it to view information about open transactions and to determine if any of them span the start point. However, because DB2 LUW log records lack timestamps, it might not be possible to make an accurate assessment. If possible, quiesce the database prior to initialization of Oracle GoldenGate.
For more information on initializing the Oracle GoldenGate environment, see Instantiating Oracle GoldenGate with an Initial Load in Administering Oracle GoldenGate.
Parent topic: Preparing the System for Oracle GoldenGate
For an Oracle GoldenGate process to connect to the correct DB2 LUW database, you must specify the name (not an alias) of the DB2 LUW database with the following parameters:
Specify the DB2 source database with the Extract parameter SOURCEDB
.
Specify the DB2 target database name with the Replicat parameter TARGETDB
.
For more information about these parameters, see the Reference for Oracle GoldenGate for Windows and UNIX.
Parent topic: Preparing the System for Oracle GoldenGate