Retaining the Transaction Logs

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:

  1. Connect to the database.

    db2 connect to database user username using password 
    
  2. Get the database name.

    db2 list db directory 
    
  3. 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:

  1. Issue one of the following commands.

    To enable USEREXIT:

    db2 update db cfg for database using USEREXIT ON 
    

    If not using USEREXIT, use this command:

    db2 update db cfg for database using LOGRETAIN RECOVERY 
    

    To set LOGARCHMETH:

    db2 update db cfg for database using LOGARCHMETH1 LOGRETAIN 
    db2 update db cfg for database using LOGARCHMETH2 OFF 
    
  2. Make a full backup of the database by issuing the following command.
    db2 backup db database to device
    
  3. Place the backup in a directory to which DB2 LUW has access rights. If you get the following message, contact your systems administrator:
    SQL2061N An attempt to access media "device" is denied.