setup and configuration of the db2 snapshot backup with ... and...2. database layout considerations...

24
-1- Setup and Configuration of the DB2 Snapshot Backup with IBM N-Series Storage in an SAP Environment IBM Deutschland Research & Development SAP DB2 Development/Porting Team Authors: Thomas Matthä [email protected] Sergiy Malikov [email protected]

Upload: others

Post on 23-Mar-2020

43 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-1-

Setup and Configuration of the DB2 Snapshot Backup

with IBM N-Series Storage in an SAP Environment

IBM Deutschland Research & Development SAP DB2 Development/Porting Team

Authors:

Thomas Matthä [email protected]

Sergiy Malikov

[email protected]

Page 2: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-2-

Abstract

IBM DB2 Advanced Copy Services (ACS) is a new feature in DB2 9.5. It enables you to

perform a nearly-instant backup of your entire database, regardless of its size.

This feature is very advantageous in business-critical environments (for example,

various SAP applications) which run 24x7 and where performance slowdown or service

interruption during backup must be avoided.

The new term “Snapshot Backup” was introduced in DB2 9.5. Snapshot backup allows

DB2 to use the rich functionality of underlying storage systems (such as IBM N Series,

IBM TotalStorage and others) to instantly create a copy of all database data and

transaction logs without any interruptions to customers. This approach dramatically

reduces the network load, disk subsystem load and disk space which is required for full

DB2 database backup.

In this whitepaper, you will gain knowledge about setting up DB2 ACS environment in

AIX, enabling SAP-specific DB2 database layout for snapshot backup on IBM N Series

storage, and performing various types of backup/restore with ACS.

Page 3: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-3-

Acknowledgements

The following persons provided expert advice and consultation for this paper.

The authors would like to acknowledge their help:

Andreas Uhl (IBM)

Edgardo Koenig (IBM)

Thomas Ritter (IBM)

Britta Bachert (SAP)

Page 4: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-4-

Table of contents

ABSTRACT ..................................................................................................................................................................2

ACKNOWLEDGEMENTS ..........................................................................................................................................3

TABLE OF CONTENTS .............................................................................................................................................4

DISCLAIMER & TRADEMARKS..............................................................................................................................5

1. OVERVIEW – ACS FOR DB2...............................................................................................................................6

2. DATABASE LAYOUT CONSIDERATIONS WITH N SERIES STORAGE ...................................................7

2.1 Overview................................................................................................................. 7

2.2 Single-Partition Database Layout with N Series Storage........................................ 9

2.3 Multi-Partition Database Layout (DPF) with N Series Storage.............................. 11

3. IMPORTANT PREREQUISITES ........................................................................................................................14

3.1 IBM N Series Storage Prerequisites ..................................................................... 14

3.2 Filesystem Prerequisites on the Database Server................................................ 15

3.3 File Access Permissions on the Database Server ................................................ 15

3.4 Database Manager Configuration......................................................................... 15

4. CONFIGURATION OF ACS................................................................................................................................16

4.1 Sample Setup Procedure...................................................................................... 16

4.2 Monitoring DB2 ACS processes ........................................................................... 19

5. PERFORMING THE SNAPSHOT BACKUP / QUERY / RESTORE ............................................................20

5.1 Snapshot Backup / Restore of the Single-Partition Database............................... 20

5.2 Snapshot Backup / Restore of the Multi-Partition Database................................. 21

6. LIST OF LITERATURE ........................................................................................................................................24

Page 5: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-5-

Disclaimer & Trademarks

The information in this document may concern new products that IBM may or may not announce. Any

discussion of OEM products is based upon information which has been publicly available and is subject to

change. The specification of some of the features described in this presentation may change before the

General Availability date of these products.

REFERENCES IN THIS PUBLICATION TO IBM PRODUCTS, PROGRAMS, OR SERVICES DO NOT

IMPLY THAT IBM INTENDS TO MAKE THESE AVAILABLE IN ALL COUNTRIES IN WHICH IBM

OPERATES.

IBM MAY HAVE PATENTS OR PENDING PATENT APPLICATIONS COVERING SUBJECT MATTER IN

THIS DOCUMENT. THE FURNISHING OF THIS DOCUMENT DOES NOT IMPLY GIVING LICENSE TO

THESE PATENTS.

TRADEMARKS

The following terms are registered trademarks of International Business Machines Corporation in the

United States and/ or other countries: AIX, AIXwindows, AS/ 400, DB2, e( logo), IBM, IBM( logo),

Information Warehouse, Netfinity, NUMA- Q, OS/ 2, OS/ 390, OS/ 400, Parallel Sysplex, PowerPC,

PowerPC( logo), RISC System/ 6000, RS/ 6000, S/ 390, Sequent, SP2, System/ 390, The Engines of e-

business, ThinkPad, Tivoli( logo), TURBOWAYS, VisualAge, WebSphere.

The following terms are trademarks of International Business Machines Corporation in the United States

and/ or other countries: AIX/ L, AIX/ L( logo), AS/ 400e, DB2 OLAP Server, DB2 Universal Database, e-

business (logo), HACMP/ 6000, Intelligent Miner, iSeries, Network Station, UMACenter, PowerPC

Architecture, PowerPC 604, POWER2 Architecture, pSeries, Shark, SP, Tivoli Enterprise, TME 10,

Videocharger, Visualization Data Explorer, xSeries, zSeries. A full list of U. S. trademarks owned by IBM

may be found at

http:// iplswww.nas.ibm.com/wpts/trademarks/trademar.htm

NetView, Tivoli and TME are registered trademarks and TME Enterprise is a trademark of Tivoli Systems,

Inc. in the United States and/ or other countries.

Microsoft, Windows, Windows NT and the Windows logo are registered trademarks of Microsoft

Corporation in the United States and/ or other countries.

SAP and related names like SAP NetWeaver are registered trademarks of SAP AG.

UNIX is a registered trademark in the United States and other countries licensed exclusively through The

Open Group.

Oracle is a registered trademark of Oracle Corporation in the United Status and/or other countries.

LINUX is a registered trademark of Linus Torvalds.

Intel and Pentium are registered trademarks and MMX, Itanium, Pentium II Xeon and Pentium III Xeon are

trademarks of Intel Corporation in the United States and/ or other countries.

Java and all Java- based trademarks and logos are trademarks of Sun Microsystems, Inc. in the United

States and/ or other countries.

Other company, product and service names may be trademarks or service marks of others.

Page 6: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-6-

1. Overview – ACS for DB2

A new feature named DB2® Advanced Copy Services (ACS) is installed automatically

with the DB2 9.5 product. It allows you to use the snapshot technology of a storage

device to perform the data movement part of backup and restore operations.

DB2 Advanced Copy Services has built-in API driver which supports the following

storage device types:

• IBM TotalStorage SAN Volume Controller

• IBM Enterprise Storage Server Model 800

• IBM System Storage DS6000

• IBM System Storage DS8000

• IBM System Storage N Series

• NetApp V-series

DB2 ACS is only available on AIX and Linux.

When the user issues the db2 backup command with an additional option “use

snapshot”, DB2 uses the ACS API to directly communicate with the storage system

and create a snapshot of volumes which contain data and log files for a chosen

database. After that, the snapshot can be used to restore the database in several

seconds.

DB2 ACS is a limited version of the Tivoli Storage Manager for Advanced Copy Services

Software product from IBM. You can use DB2 ACS with free limited license.

This license can be used in test as well as in production environment to perform

snapshot backup and restore operations – however, with the limitation to the maximal

amount of concurrently existing snapshots. If more than 2 snapshot backups of a certain

database must be stored on the storage system for the same time, DB2 ACS can be

licensed for an extra fee, and the limitations will be removed.

Page 7: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-7-

2. Database Layout Considerations with N Series Storage

2.1 Overview

Standard SAP layout of DB2 database requires at least two independent volumes on the

IBM N-Series storage system: one volume for the data and one volume for the logfiles.

The following image shows a schematic layout of the database if the N Series system is

used to store data:

Figure 1. Standard database layout with one DB2 partition (overview)

This layout has the following benefits:

� DB2 ACS off-loads the usage of system resources during backup process from

the database server to the underlying N Series storage infrastructure

� DB2 ACS allows the database server to use the rich functionality of storage

system directly from DB2 layer, without further need in a manual snapshot

management

� N Series snapshots occupy very little disk space since they only store the delta

values to the current data blocks, instead of physically copying the entire

database with SAP data (which may have the size of several Terabytes) in the

background

Page 8: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-8-

If the SAP system is installed in partitioned database environment by using the DB2

Database Partitioning Feature (DPF), at least two volumes (data and log) should exist

on the N Series storage for every database partition – regardless whether physical or

logical partitioning is used.

The following image shows schematic layout of the partitioned database on 2 partitions:

Figure 2. Standard database layout with two DB2 partitions (overview)

Page 9: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-9-

2.2 Single-Partition Database Layout with N Series Storage

Physical database layout in an SAP system has the following structure:

(Note: <SID> or <sid> is usually replaced by the three-symbol SID of an SAP system) # directory for DB2 logfiles: /db2/<SID>/log_dir # database directory: /db2/<SID>/db2<sid> # additional directories where tablespaces are allocated: # (the amount of these directories is usually chosen # depending on required grade of data concurrency) /db2/<SID>/sapdata1 /db2/<SID>/sapdata2 /db2/<SID>/sapdata3 ... /db2/<SID>/sapdataN # directory for temporary tablespaces /db2/<SID>/saptemp1

The minimum setup requires creating log_dir directory in the NFS-mounted volume

for logs, and the database directory db2<sid> as well as all data directories

(sapdata1, sapdata2, sapdata.. , saptemp.. ) in the NFS-mounted volume

for data.

During a snapshot backup, DB2 suspends all write operations to disk before creating the

snapshot and finally continues normal operation. This procedure ensures that no

changes occur to the data during the few seconds when the snapshot of volumes is

taken.

Due to the fact that an SAP system has the log directory and multiple directories with

data on the same level in directory hierarchy (i.e., under /db2/<SID>), it is not possible

to export the entire volume on N Series storage as a single NFS filesystem.

Such layout with a single mountpoint will not allow DB2 ACS to create separate

snapshots of database data and log files.

Page 10: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-10-

There are two possible solutions with NFS mounts:

� Export separate sub-directories on the same N Series data volume for further

mounting on the server (instead of exporting the entire volume). This layout is

easier to configure and to manage.

� Create a separate volume for every directory under /db2/<SID> . This approach

introduces greater complexity (instead of single data volume, at least 6 data

volumes must be managed – assuming sapdata1-4 exist) , but may also provide a

more flexible layout.

The image below shows sample implementation of the first solution (using sub-

directories of the single volume as separate NFS mounts):

Figure 3. Standard database layout and mounts for a single-partitioned system (detailed view)

Page 11: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-11-

Host A: partition 0

Host B: partition 1

2.3 Multi-Partition Database Layout (DPF) with N Series Storage

In an example of the single-partition configuration (Chapter 2.2), we have shown that the following directories must be created on the N Series volumes and mounted per NFS:

/db2/<SID>/log_dir /db2/<SID>/db2<sid> /db2/<SID>/sapdata1 /db2/<SID>/sapdata2 /db2/<SID>/sapdata3 ... /db2/<SID>/sapdataN /db2/<SID>/saptemp1

However, in a multi-partition DB2 environment, the described directories have additional subdirectories (NODE0000 – NODExxxx) which contain data for separate database partitions.

Below is an example of directory structure for a 2-partition system which is located on two separate physical hosts:

/db2/<SID>/log_dir/NODE0000

/db2/<SID>/db2<sid>/NODE0000

/db2/<SID>/sapdata1/NODE0000

/db2/<SID>/sapdata2/NODE0000

...

/db2/<SID>/sapdataN/NODE0000

/db2/<SID>/saptemp1/NODE0000

/db2/<SID>/log_dir/NODE0001

/db2/<SID>/db2<sid>/NODE0001

/db2/<SID>/sapdata1/NODE0001

/db2/<SID>/sapdata2/NODE0001

...

/db2/<SID>/sapdataN/NODE0001

/db2/<SID>/saptemp1/NODE0001

Page 12: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-12-

If the database uses logical partitioning (i.e. multiple partitions on the same physical

database server), the NODExxxx subdirectories for multiple partitions will be located in

the same place in directory hierarchy: /db2/<SID>/<log_or_data_directory>/NODExxxx

As a consequence, the NFS mounts for multi-partition DB2 databases are different from

the single-partitioned databases: instead of mounting the directories under

“/db2/<SID>/” , mountpoints in partitioned database must be created one level

deeper in the hierarchy – i.e, every database partition must access its own directories

mounted under “/db2/<SID>/<log_or_data_directory>/NODExxxx” . This

requirement is valid both for physical and logical database partitioning.

Consider the following layout example:

Figure 4. Standard database layout and mounts for a multi-partitioned system (detailed view)

Page 13: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-13-

Note: It is highly recommended to follow the certain naming schema when using the

same N Series system to store data for multiple database partitions, for example:

# data and log volumes for DB2 partition 0

vol_data_NODE0000 vol_log_NODE0000 # data and log volumes for DB2 partition 1

vol_data_NODE0001 vol_log_NODE0001 # etc...

Otherwise, determining which volume belongs to which data or log directory of certain database partition may be very complicated.

Page 14: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-14-

3. Important prerequisites

3.1 IBM N Series Storage Prerequisites

� Users and permissions

To be able to create a snapshot of DB2 data and logs volumes, the client machine (where DB2 and SAP are installed) requires a UserID with sufficient permissions on the N Series storage system.

Considering that only a small subset of storage system functions is required to create snapshots and restore data from them, it is highly recommended NOT to use the root user on N Series for this purpose.

The N Series user account requires the following minimum set of permissions for DB2 ACS snapshot backups:

login-http-admin,api-snap*,api-system-*,api-volume-options-list*

(these permissions can be specified with the “-a” option when creating a user role on N Series storage)

� Required licenses

Snapshot Create function is available on N Series free of charge.

However, IBM N Series storage system must have two additional licenses for proper

DB2 snapshot backup support:

o nfs (for NFS protocol support)

o snaprestore (for Snapshot Restore function)

You can check whether these additional licenses are installed by executing the

license command from your N Series command console:

nseries> license

………

nfs <license_code>

snaprestore <license_code>

………

Page 15: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-15-

3.2 Filesystem Prerequisites on the Database Server

� CAUTION: All NFS mounts from N Series storage on the database server must be

persistent - i.e., registered in the “/etc/filesystems” file on the server and

automatically mounted after a reboot.

Otherwise, DB2 ACS device agent will successfully unmount the required directories

during DB2 snapshot restore processing, but will be unable to mount these

directories again.

3.3 File Access Permissions on the Database Server

� In order to have sufficient permissions for mount and umount , the following files in

the /db2/db2<sid>/sqllib/acs directory must have the owner root and are

required to have the s-bit set (-rwsr-x---) :

/db2/db2<sid>/sqllib/acs/acscim

/db2/db2<sid>/sqllib/acs/acsnnas

/db2/db2<sid>/sqllib/acs/acsnsan

Usually, ACS installation script sets these permissions automatically. If, for some

reason, the s-bit is missing, ACS will be unable to perform its functions.You can

issue the following commands as user root to resolve this problem:

bash# cd /db2/db2<sid>/sqllib/acs/

bash# chown root acscim acsnnas acsnsan

bash# chmod 4750 acscim acsnnas acsnsan

3.4 Database Manager Configuration

The restore of a snapshot backup in a DPF Environment is done sequentially, partition by partition. After the restore of the first partition, DB2 creates pseudo-entries for the database directory on all other partitions. The database manager configuration parameter DFTDBPATH must be set to /db2/<DBSID> (DBSID of the database to be restored), to make sure, that the pseudo database directories are created correctly for the other partitions.

Page 16: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-16-

4. Configuration of ACS

4.1 Sample Setup Procedure

DB2 ACS can be configured by executing the script “setup.sh” in the directory /db2/db2<sid>/sqllib/acs .

Following is the description of the sample input for the setup script (user input is marked with the bold text):

bash# cd /db2/db2tm1/sqllib/acs/

bash# ./setup.sh

Do you have a full TSM license to enable all features of TSM for ACS ?[y/n]

n

****** Profile parameters for section GLOBAL: ******

ACS_DIR [/db2/db2tm1/sqllib/acs ] <press Enter to confirm default setting>

ACSD [localhost 57328 ] <press Enter to confirm default setting>

TRACE [NO ] <press Enter to confirm default setting>

****** Profile parameters for section ACSD: ******

ACS_REPOSITORY *mandatory parameter*

/db2/db2tm1/sqllib/acs/acs_repos

****** Profile parameters for section CLIENT: ******

MAX_VERSIONS [ADAPTIVE ] 2

LVM_FREEZE_THAW [YES ] <press Enter to confirm default setting>

DEVICE_CLASS [STANDARD ] <press Enter to confirm default setting>

****** Profile parameters for section STANDARD: ******

COPYSERVICES_HARDWARE_TYPE *mandatory parameter* NAS_NSERIES

COPYSERVICES_PRIMARY_SERVERNAME *mandatory parameter* db6nas

COPYSERVICES_USERNAME [superuser ] snap_user

The profile has beeen successfully created.

Do you want to continue by specifying passwords for the defined devices? [y/n]

y

Page 17: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-17-

Please specify the passwords for the following profile sections:

STANDARD <type password in the same line and press Enter>

master <type password in the same line and press Enter>

Creating password file at /db2/db2tm1/sqllib/acs/shared/pwd.acsd.

A copy of this file needs to be available to all components that connect to acsd.

BKI1555I: Profile successfully created. Performing additional checks. Make sure to restart all ACS components to reload the profile.

The parameters in the example above have the following meaning:

ACS_DIR: Base directory of ACS where the configuration file “profile” will be stored. Two additional subdirectories (“logs” and “shared”) will be created in this directory.

Caution: If you specify the directory /db2/db2<sid>/sqllib/acs as ACS_DIR,

your ACS configuration will be overwritten during DB2 upgrade or Fixpak install.

Therefore, we recommend to create another directory outside of

/db2/db2<sid>/sqllib (for example, /db2/db2<sid>/acs_dir ), which will

not be altered by DB2 upgrade.

ACSD: Hostname and port number where ACS daemon will run. In multi-partition DB2 environment (DPF), the only instance of ACS daemon must run on the host where the first database partition (i.e. catalog partition) is located.

TRACE: Specify NO

ACS_REPOSITORY: Specify a directory called “acs_repos” as a subdirectory of “ACS_DIR” above. This directory will be used to store ACS metadata.

MAX_VERSIONS: The maximum number of snapshots which can be simultaneously stored for the database. When further snapshots are taken, the oldest ones will be automatically deleted. If the ACS software is not licensed, the maximum number of snapshots is 2.

LVM_FREEZE_THAW: specify YES

DEVICE_CLASS: specify STANDARD

Page 18: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-18-

COPYSERVICES_HARDWARE_TYPE: This parameter specifies the storage system type. For IBM N-Series (which is the scope of this paper), specify NAS_NSERIES.

COPYSERVICES_PRIMARY_SERVERNAME: Hostname of the N Series storage system.

COPYSERVICES_USERNAME: Username which will be used to connect to the N-Series storage. Sample instructions for creating the N-Series user can be found in Chapter 3.1 of this paper.

When you are asked to specify the passwords, enter “y”

STANDARD password: This is the password for the user specified under COPYSERICES_USERNAME parameter to connect to the N-Series machine.

MASTER password: This password is used by clients to connect to the acsd daemon. This password can be set to any value.

Note: To change STANDARD and MASTER passwords later, type

acsd -f password

and enter the new STANDARD and MASTER passwords.

After entering all required information, the setup is complete and DB2 ACS daemon processes are started automatically in background. See chapter 4.2 for details about monitoring of ACS processes.

Note:

When the ACS configuration is done, a password file is created. This password file is written in encrypted form to a subdirectory “shared” of the ACS_DIR directory.

On physically partitioned database system, this directory must be shared over NFS with all database hosts to provide other hosts with the access to the ACS password file.

Page 19: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-19-

4.2 Monitoring DB2 ACS processes

After the setup is done, setup.sh creates entries for acsd and acsnnas in the

/etc/inittab file with an automatic respawn option:

bash# cat /etc/inittab | grep acs

ac00:2345:respawn:/db2/db2tm1/sqllib/acs/acsnnas -D

ac01:2345:respawn:/db2/db2tm1/sqllib/acs/acsd

This procedure ensures that later both processes will started automatically after

operating system boot or after process termination.

To monitor the processes, use “ps” command:

bash# ps -ef | grep acs

db2tm1 839756 1 0 08:35:32 - 0:34 /db2/db2tm1/sqllib/acs/acsd

db2tm1 1105938 1 0 10:42:38 - 0:00 /db2/db2tm1/sqllib/acs/acsnnas -D

Page 20: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-20-

5. Performing the Snapshot Backup / Query / Restore

In this chapter, the main attention will be paid to the process of taking snapshot backups

of the DB2 database as well as restoring from them.

Backup and restore commands will be described in brief form which shows the specific

options which are relevant to the scope of this whitepaper.

You can find the full syntax of the DB2 backup and restore commands in the IBM DB2

9.5 Information Center for Linux, Unix and Windows:

http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/

5.1 Snapshot Backup / Restore of the Single-Partition Database

� To perform an offline snapshot backup of the database, issue the following

command:

db2 backup db <sid> use snapshot

Alternatively, you can take an online snapshot backup of the database:

db2 backup db <sid> online use snapshot

Note: In DB2 9.5, option “INCLUDE LOGS” is the default setting for the backup

command. As a consequence, a snapshot of the log volume is also created by

default when you issue the backup command, even if an offline backup is

performed.

You can explicitely specify an option “EXCLUDE LOGS” in the backup command to

take only a snapshot of the data volume.

� Existing snapshot backups can be listed with the command

db2acsutil query

Page 21: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-21-

� To delete certain snapshot backup, call

db2acsutil delete taken at <timestamp>

� To restore your database from a previously taken snapshot backup, use the following

command:

db2 restore db <sid> use snapshot

Note: If the LOGTARGET option is not specified for the restore command, the

default option “LOGTARGET EXCLUDE” is used. As a consequence, the database

log directory is not restored from snapshot, and existing logfiles are left intact. After

restoring only the data volume from the snapshot, you can perform a rollforward

operation with existing logfiles.

When you specify the “LOGTARGET INCLUDE” option, the log directory is replaced

by the snapshot restore. Then you may only do a crash recovery of the database to

a consistent state, but no rollforward recovery is possible.

5.2 Snapshot Backup / Restore of the Multi-Partition Database

The principles of snapshot backup or restore of the multi-partition DB2 database are

similar to the backup/restore of a single-partition database.

However, there are certain differences which should be taken into account when

managing the backups of multiple database partitions.

� Snapshot backup of the partitioned database can be created by one of the following

methods:

a) Create a Single System View backup (backups of all partitions are taken

simultaneously with one command and have identical timestamp):

db2 backup db <sid> on all dbpartitionnums use snapshot

Page 22: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-22-

b) To create a snapshot backup of all database partitions (catalog partition first, then

each other partition sequentially), call:

db2 backup db <sid> on dbpartitionnum 0 use snapshot

db2 backup db <sid> on dbpartitionnum 1 use snapshot

...

db2 backup db <sid> on dbpartitionnum <part_num> use snapshot

c) Use the db2_all tool to perform the backup on all partitions (catalog partition

first, then all other partitions):

# create the backup of partition 0 only

db2_all ‘ <<+0< db2 “backup db <sid> use snapshot” ’

# after that, create backups of all partitions except 0

db2_all ‘ <<-0< db2 “backup db <sid> use snapshot” ’

d) For all database partitions, set the environment variable DB2NODE to the partition

number and then execute the backup command (catalog partition first, then all

other partitions):

export DB2NODE=0

db2 terminate

db2 backup db <sid> use snapshot

export DB2NODE=1

db2 terminate

db2 backup db <sid> use snapshot

...

Page 23: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-23-

� Partitioned database can be restored from snapshot backup by choosing one of 2 available methods:

a) Use the db2_all tool to restore all partitions from snapshot backup (catalog partition first, then all other partitions):

# restore partition 0 from snapshot backup

db2_all ‘ <<+0< db2 “restore db <sid> use snapshot” ’

# after that, restore all other partitions except 0

db2_all ‘ <<-0< db2 “restore db <sid> use snapshot” ’

b) For all database partitions, set the environment variable DB2NODE to the partition

number and then execute the restore command (catalog partition first, then all

other partitions):

export DB2NODE=0

db2 terminate

db2 restore db <sid> use snapshot

export DB2NODE=1

db2 terminate

db2 restore db <sid> use snapshot

...

Page 24: Setup and Configuration of the DB2 Snapshot Backup with ... and...2. Database Layout Considerations with N Series Storage 2.1 Overview Standard SAP layout of DB2 database requires

-24-

6. List of Literature

1. Tivoli Storage Manager for Advanced Copy Services: Installation and User Guide

http://publib.boulder.ibm.com/infocenter/tivihelp/v1r1/topic/com.ibm.itsmfacs.doc/fbrd0000.pdf

2. Database Administration Guide: SAP on IBM DB2 for Linux, UNIX, and Windows

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/82e754ff-0701-0010-32bd-acb2be34e9ff

3. Redbook: “Integrating IBM DB2 with IBM System Storage N Series”

http://www.ibm.com/redbooks/redpieces/abstracts/sg247329.html?Open

4. IBM DB2 9.5 Information Center for Linux, UNIX, and Windows

http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/

5. Redbook: “High Availability and Disaster Recovery Options for DB2 on Linux, UNIX, and Windows”

http://www.redbooks.ibm.com/redpieces/pdfs/sg247363.pdf