Replication Guide and Reference

Capture and Apply for UNIX platforms

This chapter describes how to set up and operate the Capture and Apply programs on the following UNIX platforms:

Be sure to read the following sections before reading the sections on operating the Capture and Apply programs:


User ID requirements for running the Capture and Apply programs

Before you set up the Capture and Apply programs, you must set up a UNIX user account to run the programs. Ensure that the user ID under which the Capture and Apply programs will run has the required privileges:


Setting up the Capture and Apply programs

Setting up consists of configuring the source, target, and control servers. The following sections provide instructions for configuring each server as well as information about setting up end-user authentication at the source server.

Configuring the Capture program for UNIX platforms

  1. Log on with a user ID that has sufficient privileges.
  2. Connect to the source server database by entering:
    db2 connect to database
    

    where database is the source server database.

  3. Prepare the source server database for roll-forward recovery by issuing the update database configuration command and the backup database command. For example:
    db2 update database configuration for database_alias using logretain on
    db2 backup database database_alias
    
    or:
    db2 update database configuration for database_alias using userexit on
    db2 backup database database_alias
    
    You might need to increase DBHEAP, APPLHEAPSZ, PCKCACHESZ, LOCKLIST, and LOGBUFSZ based on your installation requirements.
  4. Optional: The Capture program is bound automatically during execution; however, if you want to specify options or check that all bind processes complete successfully, complete the following steps:
    1. Change to the directory where the Capture program bind files are located, which is usually $HOME/sqllib/bnd.
    2. Create and bind the Capture program package to the source server database by entering the following command:
      db2 bind @capture.lst isolation ur blocking all
      

      where ur specifies the list in uncommitted read format for greater performance.

    These commands create a list of packages, the names of which are in the file CAPTURE.LST.

Optional: Configuring the Apply program manually for UNIX platforms

Important: The Apply package is bound automatically during execution. Therefore, the following steps for binding the Apply package on UNIX are optional. If you want to specify options or check that all bind processes completed successfully, complete the following steps:

  1. Log on with a user ID that has sufficient privileges.
  2. Change to the directory where the Apply program bind files are located, which is usually $HOME/sqllib/bnd.
  3. For each source, target, and control server to which the Apply program connects, do the following steps:
    1. Connect to the server database by entering:
      db2 connect to database
      
      where database is the source, target, or control server .
      Note:If the server database is cataloged as a remote database, you might need to specify a user ID and password on the db2 connect to command. For example:
      db2 connect to database user userid using password
      
    2. Create and bind the Apply program package to the server database by entering the following commands:
      db2 bind @applycs.lst isolation cs blocking all grant public
      
      db2 bind @applyur.lst isolation ur blocking all grant public
      
      where cs specifies the list in cursor stability format, and ur specifies the list in uncommitted read format.

      Because the Apply program control tables use static SQL calls for the control tables, the Apply bind process searches for the control tables at each server that the Apply program is bound to, regardless of whether these control tables are used at a server.

    These commands create a list of packages, the names of which are in the files APPLYCS.LST and APPLYUS.LST.

Other configuration considerations for UNIX-based components

Ensure that the user ID from which the Capture and Apply programs are running has write privilege on the directories where you invoke the programs. Write privilege is necessary because both the Capture and Apply programs create files in the invocation directory.

The Capture program creates the following files in addition to the spill files:

instnameSRCSRVR.ccp
A log file for the messages issued by the Capture program. These messages are also recorded in the trace table.

instnameSRCSRVR.tmp
A file that contains the process ID of this invocation of the Capture program (to prevent multiple Capture programs from being started in the same instance on the same source server).

The Apply program creates the following files:

APPLYQUAL.app
A log file for the messages issued by the Apply program. These messages are also recorded in the Apply trail table.

ASNAPPLYAPPLYQUAL.pid
A file that contains the process ID of this invocation of the Apply program. This prevents multiple Apply programs from being started with the same Apply qualifier.

For more information about configuration of UNIX-based components, see IBM DB2 Universal Database for UNIX Quick Beginnings.

Setting up end-user authentication at the source server

In some cases you must provide a password file for end-user authentication to occur at the source server. The Apply program uses this file when connecting to the source server. Give read access to only the user ID that will run the Apply program. Environment-specific requirements include:

Creating a password file:

The password file must meet the following criteria:

If you do not create a password file:

The Apply program for UNIX must be able to issue an SQL CONNECT statement without specifying the user ID and password. If the Apply program needs to connect to an OS/390 database with SNA connectivity, these settings are necessary:

For more information about authentication and security, refer to the IBM DB2 Universal Database Administration Guide.


Operating Capture for UNIX platforms

An administrator can use the commands in this section to operate the Capture program for UNIX platforms. Enter the commands or a key combination from a UNIX command line.

This section explains how to perform the following Capture program tasks:

This section also lists restrictions for running the Capture program.

Restrictions for running the Capture program

Some actions cause the Capture program to terminate while it is running. Stop the Capture program before you take any of the following actions:

The Capture program cannot capture any changes made by DB2 utilities, because the utilities do not log the changes that they make.

Scheduling Capture for UNIX platforms

Use the at command to start the Capture program at a specific time. For example, the following command starts the Capture program at 3:00 p.m. on Friday:

at 3pm Friday asnccp warmns noprune

Setting environment variables for Capture for UNIX platforms

You must set two environment variables before you start the Capture program. These variables must also be set when you use any of the following functions:

To set the environment variables:

  1. Set the environment variable for the DB2 instance name (DB2INSTANCE) as shown:
    export DB2INSTANCE=db2_instance_name
    
  2. Optional: Set environment variable DB2DBDFT to the source server.

Starting Capture for UNIX platforms

After you start the Capture program, it runs continuously until you stop it or it detects an unrecoverable error.

To start the Capture program for a UNIX platform:

  1. Log in and make sure that the user ID under which the Capture program is running has write privilege on the directory.
  2. Ensure that you set the DB2 instance name as shown:
    export DB2INSTANCE=db2_instance_name
    

    While the Capture program is running, a file with the name Database_instance_nameDatabase_name.ccp is created in the directory from which the Capture program is started. This file is a log file for the messages issued by the Capture program; these messages are also recorded in the trace table.

  3. Optional: Set environment variable DB2DBDFT to the source server.
  4. Set the LIBPATH environment variable to the directory in which the Capture program starts. Note that in the following examples the language environment variables depend on the language that you install, and that db2homedir is the DB2 instance home directory.

    AIX example:

    export LIBPATH=db2homedir/sqllib/lib:/usr/lib:/lib
    export LANG=en_US
    

    HP-UX example:

    export SHLIB_PATH=db2homedir/sqllib/lib:/usr/lib:/lib
    export LANG=en_US
    

    Linux example:

    export LD_LIBRARY_PATH=db2homedir/sqllib/lib:/usr/lib:/lib:/db2/linux/lib 
    export LANG=en_US                 
     
    

    NUMA-Q example:

    export LD_LIBRARY_PATH=db2homedir/sqllib/lib:/opt/jse3.0/lib
    export LANG=en_US
     
    

    Solaris example:

    export LD_LIBRARY_PATH=db2homedir/sqllib/lib:/usr/lib:/lib
    export LANG=en_US
    export NLSPATH=/usr/lib/locale/%L/%N:/db2homedir/sqllib/msg/en_US/%N
    
  5. Enter the following command:
>>-asnccp----+------------+---+--------+---+---------+---------->
             '-src_server-'   +-warm---+   +-prune---+
                              +-warmns-+   '-noprune-'
                              '-cold---'
 
>-----+---------+---+---------+---+----------+---+----------+--->
      +-notrace-+   '-trcfile-'   '-notrctbl-'   '-autostop-'
      '-trace---'
 
>-----+----------+---+-----------+---+---------+---------------><
      '-logreuse-'   '-logstdout-'   +-allchg--+
                                     '-chgonly-'
 

Table 27 defines the invocation parameters.

Table 27. ASNCCP invocation parameter definitions for UNIX platforms
Parameter Definition
src_server Source server name must be the first parameter if entered. If not specified, the value from the DB2DBDFT environment variable is used.
warm  (default)  The Capture program resumes processing where it ended in its previous run if warm start information is available. If the Capture program cannot warm start, it switches to a cold start.
warmns The Capture program resumes processing where it ended in its previous run if warm start information is available. Otherwise, it issues a message and terminates. With warmns, the Capture program does not automatically switch to a cold start. The Capture program leaves the trace, UOW, CD, and warm start tables intact. In case of errors, the Capture program terminates instead of switching to a cold start as when warm is specified.
cold The Capture program starts by deleting all rows in its CD table, UOW table, and trace table during initialization. All subscriptions to these replication sources will be fully refreshed during the next Apply processing cycle. A full refresh is not done if the target is a noncomplete CCD table (see Resolving gaps between source and target tables).
prune  (default)  The Capture program automatically prunes the rows in the CD and UOW tables that the Apply program has copied, at the interval specified in the tuning parameters table. In addition, the Capture program also prunes the CD and UOW rows that are older than the retention limit even though they have not been copied during warm start.
noprune Automatic pruning is disabled. The Capture program prunes the CD and the UOW tables only when you enter the prune command.
notrace  (default)  No trace information is written.
trace Writes trace messages to the standard output, stdout, unless trcfile is also specified.
trcfile If both trcfile and trace are specified, the Capture program writes trace output to the trace file (*.trc). If you do not specify this option, the Capture program sends trace output to the standard output, stdout.
notrctbl The Capture program messages are not logged in the trace table.
autostop The Capture program terminates after it captures all transactions logged before the Capture program was started.
logreuse The Capture program reuses the log file (*.ccp) by first deleting it and then recreating it when the Capture program is restarted. If you do not specify this option, the Capture program appends messages to the log file, even after the Capture program is restarted.
logstdout The Capture program sends all messages to both the standard output (stdout) and the log file.
allchg  (default)  Specifies that an entry is made to the CD table whenever any source table row changes.
chgonly Specifies that an entry is made to the CD table when a source table row changes only if the columns defined for replication (CD table columns) change values.

Stopping Capture for UNIX platforms

Use the stop command or a key combination to stop the Capture program in an orderly way and commit the log records that it processed up to that point. You must stop the Capture program before removing or modifying an existing replication source.

Before you stop the Capture program, ensure that the environment variables are set (see Setting environment variables for Capture for UNIX platforms). To stop the Capture program, enter the command:

If you set environment variable DB2DBDFT (see step 2):

>>-asncmd--stop------------------------------------------------><
 

or, if you did not set environment variable DB2DBDFT:

>>-asncmd--src_server--stop------------------------------------><
 

Suspending Capture for UNIX platforms

Use the suspend command to relinquish operating system resources to operational transactions during peak periods without destroying the Capture program environment. This command suspends the Capture program until you issue the resume command.

Before you suspend the Capture program, ensure that the environment variables are set (see Setting environment variables for Capture for UNIX platforms). To suspend the Capture program, enter the command:

If you set environment variable DB2DBDFT (see step 2):

>>-asncmd--suspend---------------------------------------------><
 

or, if you did not set environment variable DB2DBDFT:

>>-asncmd--src_server--suspend---------------------------------><
 

Important: Do not use the suspend command when canceling a replication source. Instead, stop the Capture program.

Resuming Capture for UNIX platforms

Use the resume command to restart the Capture program if you suspended it using the suspend command.

Before you resume the Capture program, ensure that the environment variables are set (see Setting environment variables for Capture for UNIX platforms). To resume the Capture program, enter the command:

If you set environment variable DB2DBDFT (see step 2):

>>-asncmd--resume----------------------------------------------><
 

or, if you did not set environment variable DB2DBDFT:

>>-asncmd--src_server--resume----------------------------------><
 

Reinitializing Capture for UNIX platforms

Use the reinit command to begin to capture changes from new source tables if you add a new replication source or ALTER ADD a column to a replication source and CD table while the Capture program is running. The reinit command tells the Capture program to obtain newly added replication sources from the register table.

reinit also rereads the tuning parameters table for any changes made to the tuning parameters.

Before you reinitialize the Capture program, ensure that the environment variables are set (see Setting environment variables for Capture for UNIX platforms). To reinitialize the Capture program, enter the command:

If you set environment variable DB2DBDFT (see step 2):

>>-asncmd--reinit----------------------------------------------><
 

or, if you did not set environment variable DB2DBDFT:

>>-asncmd--src_server--reinit----------------------------------><
 

Important: Do not use the reinit command to reinitialize the Capture program after canceling a replication source or dropping a replication source table while the Capture program is running. Instead, stop the Capture program and restart it using the WARM or WARMNS option.

Pruning the change data and unit-of-work tables.

Use the prune command to start pruning the CD and UOW tables.

This command prunes tables once.

Before you begin pruning tables, ensure that the environment variables are set (see Setting environment variables for Capture for UNIX platforms). To begin pruning tables, enter the command:

If you set environment variable DB2DBDFT (see step 2):

>>-asncmd--prune-----------------------------------------------><
 

or, if you did not set environment variable DB2DBDFT:

>>-asncmd--src_server--prune-----------------------------------><
 

The Capture program issues the message ASN0124I when the command is successfully queued.

If you stop or suspend the Capture program during pruning, you must enter the prune command again to resume pruning. Pruning does not resume after you enter the resume command.

Displaying captured log progress.

Use the getlseq command to get the timestamp and current log sequence number. You can use this information to determine how far the Capture program has read the DB2 log.

Before you display captured log progress, ensure that the environment variables are set (see Setting environment variables for Capture for UNIX platforms). To display captured log progress, enter the command:

If you set environment variable DB2DBDFT (see step 2):

>>-asncmd--getlseq---------------------------------------------><
 

or, if you did not set environment variable DB2DBDFT:

>>-asncmd--src_server--getlseq---------------------------------><
 
Tip:You can use the DB2 UDB Find Log Sequence Number command (db2flsn) to identify the physical log file associated with the log sequence number. You can use this number to delete or archive log files no longer needed by the Capture program. For more information, see the IBM DB2 Universal Database Command Reference.

Operating Apply for UNIX platforms

An administrator can use the commands in the following sections to perform the following Apply program tasks:

Before you start the Apply program

Before you start the Apply program, ensure that:

Starting Apply for UNIX platforms

After you start the Apply program, it runs continuously until:

To start the Apply program on a UNIX platform:

  1. Log on with the user ID that will run the Apply program.
  2. Ensure that you set the DB2 instance name as shown:
    export DB2INSTANCE=db2_instance_name
    
  3. Set the LIBPATH and language environment variables or edit the .profile file in the same environment in which the Apply program starts. Note that in the following examples the language environment variables depend on the language that you install, and that db2homedir is the DB2 instance home directory.

    AIX example:

    export LIBPATH=db2homedir/sqllib/lib:/usr/lib:/lib
    export LANG=en_US
    

    HP-UX example:

    export SHLIB_PATH=db2homedir/sqllib/lib:/usr/lib:/lib
    export LANG=en_US
    

    Linux example:

    export LD_LIBRARY_PATH=db2homedir/sqllib/lib:/usr/lib:/lib:/db2/linux/lib 
    export LANG=en_US                 
     
    

    NUMA-Q example:

    export LD_LIBRARY_PATH=db2homedir/sqllib/lib
    export LANG=en_US
     
    

    Solaris example:

    export LD_LIBRARY_PATH=db2homedir/sqllib/lib:/usr/lib:/lib
    export NLS_PATH= /usr/lib/locale/%L/%N:db2homedir/sqllib/msg/en_US/%N
    export LANG=en_US
    
  4. Enter the asnapply command and options:
>>-asnapply--apl_qual----+-----------+---+-----------+---------->
                         '-ctrl_serv-'   +-loadxit---+
                                         '-noloadxit-'
 
>-----+----------+---+---------+---+---------+---+----------+--->
      +-inamsg---+   +-notrc---+   '-trcfile-'   +-notify---+
      '-noinamsg-'   +-trcerr--+                 '-nonotify-'
                     '-trcflow-'
 
>-----+---------+---+------------+---+----------+--------------->
      +-sleep---+   +-delay(n)---+   '-copyonce-'
      '-nosleep-'   '-errwait(n)-'
 
>-----+----------+---+-----------+---+----------+--------------><
      '-logreuse-'   '-logstdout-'   '-trlreuse-'
 

Table 28 defines the invocation parameters.

Table 28. ASNAPPLY invocation parameter definitions for UNIX platforms
Parameter Definition
apl_qual Specifies the Apply qualifier that the Apply instance uses to identify the subscription sets to be served. The Apply qualifier is case sensitive and must match the value of APPLY_QUAL in the subscription set table. This must be the first parameter.
ctrl_serv Specifies the name of the server where the replication control tables will reside. If you do not specify this parameter, the default is the default database or the value of DB2DBDFT.
loadxit Specifies that the Apply program is to invoke ASNLOAD, an IBM-supplied exit routine that uses the export and load utilities to refresh target tables.
noloadxit  (default)  Specifies that the Apply program will not invoke ASNLOAD.
inamsg  (default)  Specifies that the Apply program is to issue a message when the Apply program is inactive.
noinamsg Specifies that the Apply program will not issue this message.
notrc  (default)  Specifies that the Apply program does not generate a trace.
trcerr Specifies that the Apply program generates a trace that contains only error information.
trcflow Specifies that the Apply program generates a trace that contains both error and execution flow information.
trcfile If both trcfile and either trcerr or trcflow are specified, the Apply program writes trace output to the trace file (*.trc). If you do not specify this option, the Apply program sends trace output to the standard output, stdout.
notify Specifies that the Apply program is to invoke ASNDONE, an exit routine that returns control to the user when the Apply program finishes copying a subscription set.
nonotify  (default)  Specifies that the Apply program will not invoke ASNDONE.
sleep  (default)  Specifies that the Apply program is to go to sleep if no new subscription sets are eligible for processing.
nosleep Specifies that the Apply program is to stop if no new subscriptions are eligible for processing.
delay(n) Specifies the delay time (in seconds) at the end of each Apply cycle when continuous replication is used, where n=0, 1, 2, 3, 4, 5, or 6. The default delay time is 6 seconds.
errwait(n) Specifies the number of seconds that the Apply program waits before retrying after it encounters an error condition, where n is the number of seconds. Do not specify too small a number because the Apply program will run almost continuously and generate many rows in the Apply trail table. The default wait period is 300 seconds (5 minutes).
copyonce The Apply program executes one copy cycle for each subscription set that is eligible at the time the Apply program is invoked, and then the Apply program terminates. An eligible subscription set is such that:
  • ACTIVATE > 0
  • REFRESH_TIMING = R or B or REFRESH_TIMING = E and the specified event has occurred.
MAX_SYNCH_MINUTES and END_OF_PERIOD are honored if specified.
logreuse The Apply program reuses the log file (*.app) by first deleting it and then re-creating it when the Apply program is restarted. If you do not specify this option, the Apply program appends messages to the log file, even after the Apply program is restarted.
logstdout The Apply program sends all messages to both the standard output (stdout) and the log file.
trlreuse The Apply program empties the Apply trail table when the Apply program is started.

Scheduling Apply for UNIX platforms

Use the at command to start the Apply program at a specific time. For example, the following command starts the Apply program at 3:00 p.m. on Friday:

at 3pm Friday asnapply myqual

Stopping Apply for UNIX platforms

Use the asnastop command or a key combination to stop the Apply program in an orderly way.

To stop the Apply program, perform the following steps from a window where the Apply program is not running:

  1. Set environment variable DB2INSTANCE to the value set when the Apply program was started.
  2. Set environment variable DB2DBDFT to the source server specified when the Apply program was started (or the DB2DBDFT value used when the Apply program was started).
  3. Enter the command.
>>-asnastop--apply_qualifier-----------------------------------><
 

Footnotes:

32
Usually the Apply package is created automatically for you; however, if you configure the Apply program manually, you must explicitly bind the Apply package.


[ Top of Page | Previous Page | Next Page ]