Source:DB2 Backup

From SEPsesam
Revision as of 14:11, 7 August 2018 by Sta (talk | contribs) (Marked this version for translation)
Other languages:

Copyright © SEP AG 1999-2024. All rights reserved.

Any form of reproduction of the contents or parts of this manual is allowed only with the express written permission from SEP AG. When compiling and designing user documentation SEP AG uses great diligence and attempts to deliver accurate and correct information. However, SEP AG cannot issue a guarantee for the contents of this manual.

Docs latest icon.png Welcome to the latest SEP sesam documentation version 4.4.3/4.4.3 Grolar. For previous documentation version(s), check IBM DB2.


Overview

The procedures and features explained herein provide only information about the SEP sesam-specific parts of DB2 backup. For detailed information on DB2-specific backup and recovery, refer to DB2 administration guide.

SEP sesam online backup for IBM DB2 Universal Database (UDB) integrates with the XBSA interface of DB2 and backs up data of DB2 databases to SEP sesam Server. The XBSA API manages the access from DB2 backup utility to SEP sesam to coordinate a backup of the database. SEP sesam provides a shared library db2xbsa, which is loaded by DB2 to access SEP sesam backup and restore APIs.

The backup and restore processes, including managing storage media, are managed by SEP sesam, while DB2 API decides which data have to be backed up or recovered.

SEP sesam DB2 module (db2xbsa.so/db2xbsa.dll) is a part of SEP sesam Client, except for the DB2 module (db2xbsa.so) for the IBM AIX operating system. In the latter case, you have to download the module from http://download.sep.de/extensions/databases/db2/aix/. For details, see section Installing SEP sesam DB2 module on IBM AIX.

Requirements

To ensure error-free operation of SEP sesam and improve performance, make sure that the following conditions are met:

Adding the DB2 client to SEP sesam environment

Once you have downloaded the SEP sesam package, proceed as follows: You configure a new client by adding it to the SEP sesam environment: Main selection -> Components -> Topology -> New client -> add your DB2 client. For details, see Configuring Clients.

Information sign.png Note
Before proceeding, you should validate that you can backup to SEP sesam. Run a test Path backup manually to ensure that the backups work. For details on typical backup configuration, see Standard Backup Procedure.

Installing SEP sesam DB2 module on IBM AIX

Before downloading the DB2 module for IBM AIX, verify that SEP sesam Client is installed and added to SEP sesam environment, and make sure that the Path backup is successful, as described in previous section.

  1. Login as root user to your IBM AIX computer.
  2. Download the DB2 module from http://download.sep.de/extensions/databases/db2/aix/ to a temporary directory.
  3. Unzip the sesam-db2-aix_64-bit.tar.gz.
  4. Unpack tar file sesam-db2-aix_64-bit.tar.
  5. Deploy db2xbsa.so as described in the following section.

Example ( the file sesam-db2-aix_64-bit.tar.gz is downloaded to /tmp) :

# cd /tmp
# gunzip sesam-db2-aix_64-bit.tar.gz
# tar xf sesam-db2-aix_64-bit.tar
# cp db2xbsa.so /opt/sesam/bin/sesam
#

Deploying shared library db2xbsa

The SEP sesam DB2 package includes a shared library which DB2 server loads dynamically during backup or restore.

There are two ways in which you can use the db2xbsa.so/db2xbsa.dll library. You can either use the file located in <SESAM_ROOT>/bin/sesam directory or copy it to DB2 default library directory on the DB2 server. Note that the db2 backup command will be different depending on which method you use for shared library deployment.

Copying shared library db2xbsa into DB2 default library directory

Instead of using the shared library from the <SESAM_ROOT>/bin/sesam directory and specifying the path by the LOAD command, you can put it into the DB2 library directory on the DB2 server.

  • DB2DIR=/opt/IBM/db2/V8.1 (the DB2 product directory)
  • root@linux:~# cd /tmp/ root@linux:/tmp # cp db2xbsa.so /opt/IBM/db2/V8.1/lib
  • The used db2 backup command will be slightly different; instead of LOAD the USE XBSA command will be used. For details, see section Starting DB2 database backup.

Configuring DB2 backup

For DB2 backups, SEP sesam Server acts as a media manager. It handles media and provides scheduling, media management and monitoring for DB2 backups and restores. DB2 is responsible for the source – what is going to be backed up.

Creating a backup task with task type DB2 UDB on SEP sesam Server

Use the SEP sesam GUI to configure the DB2 backup tasks. You have to create a separate backup task for each DB2 database you want to back up.

  1. From Main Selection -> Tasks -> By clients, select DB2 client and click New backup task. The New backup task window opens.
  2. Enter the Task name, e.g., DB2_SAMPLE.
  3. As task type, select DB2 UDB.
  4. Specify the Source; since you have to create a separate backup task for each DB2 database you want to back up, the source must be specified accordingly, e.g., specify a database SAMPLE for the backup task DB2_SAMPLE, and database PROD for a task DB2_PROD, etc.
  5. File:Bck DB2.png
  6. Click OK to create the task.
  7. Create a new command event for scheduling the DB2 backup (and, if necessary, set permission to execute commands). You can insert the backup start command into a script on the DB2 server and then trigger the script by SEP sesam command event. For details, see Creating a Command Event.

Configuration on DB2 server

DB2 provides the ability to perform online backups, allowing applications to use the database while backups are being taken. To enable this, you need to provide SEP sesam information to DB2 and configure specific DB2 database configuration parameters.

SEP sesam parameters for DB2

First, you have to provide DB2 the following relevant parameters to connect to SEP sesam Server. Edit the db2.conf file to provide information about the database, the policy and schedule which will be used.

SESAM_SERVER
The name of SEP sesam Server
SESAM_JOB
The name of the previously configured DB2 backup task (with task type DB2 UDB), e.g., DB2_SAMPLE
SESAM_POOL
The name of already configured media pool on SEP sesam Server
SESAM_TAPE_SERVER (optional)
Name of Remote Device Server to use
SESAM_DRIVE (optional)
Number of the SEP sesam drive that you want to use for backup
XBSA_TRACE (optional)
<Trace level> (0|1|2|3) (if set with +128, then log XBSA trace output to STDERR, e.g. 2+128 -> 'set XBSA_TRACE=130')
XBSA_LOGFILE (optional)
<Full pathname of trace file sdb2.log>

Some of the parameters are optional, but even though the XBSA_TRACE and XBSA_LOGFILE are not mandatory, they should be set to provide information in case of problems during backup or restore.

DB2 configuration parameters

Before you modify the DB2 database configuration parameters, make sure that no applications are currently using the DB2 database.

In order to enable online backups, you have to enable archive logging for DB2. By default, circular logging is enabled after creating a database; it only allows to take offline backups. To enable archive logging, you need to modify the LOGARCHMETH1 database configuration parameter. Archive logging also allows to restore a database from a backup image and roll forward to a particular point using logs thus getting it to a consistent state.

LOGARCHMETH1 and LOGARCHOPT1 – automatic archive log backup to SEP sesam
LOGARCHMETH1 parameter is used to archive and handle the DB2 database log files. Values are OFF, RETAIN, USEREXIT, DISK, TSM, and VENDOR. The latter must be set to specify that a vendor library – in case of SEP sesam db2xbsa.so or db2xbsa.dll – is used to archive the log files. The value must be followed by a colon(:) and the shared library name db2xbsa.so/db2xbsa.dll.
LOGARCHOPT1 parameter is used to define the sesam parameters for the archive log backup. See above section SEP sesam parameters for DB2.

To enable archive logging and interactively update LOGARCHMETH1 and LOGARCHOPT1 parameters, enter the following from the DB2 console:

db2 update db cfg for <database_name> using logarchmeth1 "VENDOR:<install path><shared library name>"
db2 update db cfg for <database_name> using logarchopt1 "SESAM_SERVER=<name>;SESAM_JOB=<your_task>;SESAM_POOL_<your_pool>"
SEP Tip.png Tip
You can also add optional parameters to the LOGARCHOPT1 parameter, such as SESAM_TAPE_SERVER, SESAM_DRIVE, XBSA_TRACE and XBSA_LOGFILE.

For example, on Linux:

db2 update db cfg for test_db using logarchmeth1 "VENDOR:/opt/sesam/bin/sesam/db2xbsa.so"
db2 update db cfg for test_db using logarchopt1 "SESAM_SERVER=qsfix;SESAM_JOBS=db2_test_db;SESAM_POOL=Disk_Pool"

On Windows operating systems, specify the path name using UNC addressing (such as \\Program Files\SEPsesam\bin\sesam\) or drive letters (such as c:\Program Files\SEPsesam\bin\sesam\). For example:

db2 update db cfg for test_db using logarchmeth1 "VENDOR:\\Program Files\SEPsesam\bin\sesam\db2xbsa.dll"

For more information on the LOGARCHMETH1 parameter, see IBM logarchmeth1 documentation.

VENDOROPT – default values for DB backup
VENDOROPT parameter is used to specify default values for backing up the database. Enter the following from the DB2 console:
db2 update db cfg for <database_name> using vendoropt "SESAM_SERVER=<name>;SESAM_JOB=<your_task>;SESAM_POOL_<your_pool>"

For example:

db2 update db cfg for test_db using using vendoropt "SESAM_SERVER=qsfix;SESAM_JOBS=db2_test_db;SESAM_POOL=Disk_Pool"
SEP Tip.png Tip
You can also add optional parameters to the to the VENDOROPT parameter, such as SESAM_TAPE_SERVER, SESAM_DRIVE, XBSA_TRACE and XBSA_LOGFILE.

For more information on VENDOROPT parameter, see IBM vendoropt documentation.

The update to set parameters takes effect during the next log file archive.

Once you set the above parameters, you have to perform one offline backup before any connections can be made to the DB2 database (DB2 goes into a backup pending state when this parameter is enabled); therefore no users can be connected. After that you can run scheduled online backups.

TRACKMOD – incremental backup
Additionally, you can set the TRACKMOD to enable incremental backups. When set to ON, the DB2 database manager will track database modifications and enable SEP sesam to detect which subsets of the database pages must be examined by an incremental backup. For more information on TRACKMOD parameter, see IBM trackmod documentation.

To enable incremental backups, enter the following from the DB2 console:

db2 update db cfg for <database name> using TRACKMOD on

For example:

db2 update db cfg for <database name> using TRACKMOD on

After you set the TRACKMOD, you must run a full offline database backup to update the parameter and enable incremental backups. Without a full offline backup the TRACKMOD parameter will not take effect.

Starting database backup

The command for starting a DB2 backup depends on the method you used for deploying shared library.

SEP Tip.png Tip
You can use a command event for scheduling the DB2 backup. Create a script with the backup start command on the DB2 server and then trigger the script by SEP sesam command event. For details, see Creating a Command Event.

If the db2xbsa library is located in the <SESAM_ROOT>/bin/sesam directory, use the LOAD command together with specified library path:

 db2inst@linux:~>db2 BACKUP DATABASE sample_db ONLINE \
                     LOAD /opt/sesam/bin/sesam/db2xbsa.so \
                     OPTIONS 'SESAM_SERVER=midrangix;SESAM_JOB=db2_sample_db; \
                     SESAM_POOL=DISK;XBSA_LOGFILE=/home/db2inst1/sdb2.log; \
                     XBSA_TRACE=1' INCLUDE LOGS WITHOUT PROMPTING;

If the db2xbsa is located in the DB2 default library directory on DB2 server, use the USE XBSA command:

db2inst@linux:~>db2 BACKUP DATABASE sample_db ONLINE USE XBSA \
                     OPTIONS 'SESAM_SERVER=midrangix;SESAM_JOB=db2_sample_db; \
                     SESAM_POOL=DISK;XBSA_LOGFILE=/home/db2inst1/sdb2.log; \
                     XBSA_TRACE=1' INCLUDE LOGS WITHOUT PROMPTING;
SEP Tip.png Tip
If the VENDOROPT parameter is set, it is not required to use the OPTIONS parameter. The db2 backup will use the values defined by VENDOROPT.
db2inst@linux:~>db2 BACKUP DATABASE sample_db ONLINE \
                LOAD /opt/sesam/bin/sesam/db2xbsa.so \
                INCLUDE LOGS WITHOUT PROMPTING;

Troubleshooting

For troubleshooting IBM DB2 issues, see Troubleshooting IBM DB2.

See also

DB2 Restore