How to Enable SQL Replication for DB2

Issue

Enabling SQL replication for DB2.

Solution

References

Note: The table on which you want to enable replication must have a unique index defined. In this case, the replication table is ABC.EMPLOYEE, and the database used is WESTERN.

The following capture program replicates the data from ABC.EMPLOYEE to ABC.CDEMPLOYEE and ABC.TGEMPLOYEE.

Follow the steps below to enable SQL replication for DB2:

Create sqlrep.asnclp script with the following content:

Copy

To create the script from IBM, refer https://www.ibm.com/support/knowledgecenter/en/SSTRGZ_11.4.0/com.ibm.swg.im.iis.db.repl.asnclp.sql.doc/topics/iiyrsclpbldscriptsql.html .

After creating the script, run it using the following command:

$DB2HOME/bin/asnclp -f

This creates all the tables required for SQL replication in a separate schema called ASM. This registers the table for replication, but does not replicate the data.

After running the asnclp program, start the SQL Replication Capture (asncap) program for the database used, from a DB2 command window in the background, using the following command:

asncap capture_server=western &

Run apply program in the background using the following command:

asnapply controlserver=western apply qual=MYQUALWESTERNTE &

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard