Skip to main content
Pure1 Support Portal

Web Guide: DB2 Database Protection And Copy Using FlashArray Snapshots

Introduction

Volume snapshots are immutable, point-in-time images of the contents of one or more volumes.

FlashArray User Guide

Database and storage administrators are tasked with protecting and ensuring data integrity. Additionally, they may be asked to create a copy of existing databases for testing and development purposes. FlashArray-based snapshots make those assignments quick and simple. Snapshots can be used to easily duplicate the database content and to make it available on another host. The process of creating FlashArray-based snapshots is simple and instantaneous, without negative impact to the array's performance.

DB2 from IBM, a popular relational database engine available on Linux, Unix and Windows, is also supported on FlashArray.

This article describes how to protect a single-partition active DB2 database using FlashArray-based snapshots and how to utilize snapshots to create the same database on another host. The two common DB2 implementations on Linux and AIX are depicted. A typical scenario is shown in Figure 1 where DB2 Host A is the source and DB2 Host B is a target for duplicated database.

db2_snap.png

Figure 1

Audience

Database, storage and backup administrators as well as IT managers interested in exploring FlashArray snapshot technology are the primary audience for this article. Essential familiarity with FlashArray, operating system, file systems and DB2 database is required.

Environment 

AIX

Operating System AIX Version 7.2.0.0
File System JFS2
Database Version DB2 11.1.2.2
Database Instance Located on a dedicated volume group with single logical volume on two FlashArray physical volumes
Database Located on the same file system as database instance

Linux

Operating System Ubuntu 16.04.3 LTS; Linux kernel 4.4.0.116-generic
File System xfs
Database Version DB2 11.1.2.2
Database Instance Located on / (root) file system
Database
  • Located on a single dedicated volume based on a single FlashArray physical volume
  • Located on a single volume group with single logical volume striped across two FlashArray physical volumes

Procedure

The process of creating a database copy using FlashArray snapshots consists of the following steps:

  1. FlashArray
    1. Snapshot volumes on FlashArray
    2. Copy snapshots to new volumes
    3. Connect host(s) to new volumes
  2. Target Host(s)
    1. Configure volumes created in step 1c (on FlashArray)
    2. Mount file system(s)
    3. Start the database

FlashArray

The process of taking the volume snapshot on FlashArray is operating system independent. For simultaneous multiple volume snapshots it is recommended to use Protection Groups. Protection Groups are groups of volumes, hosts, or hosts groups which are protected together through snapshots.

BEST PRACTICE: Create Protection Group or Protection Groups for volume snapshots.

Create Protection Group

Using Command Line Interface:

purepgroup create --vollist <volumes> pgroup

where:

vollist - comma separated list of volumes to be included in the protection group

pgroup - name of the Protection Group

Example:

purepgroup create --vollist DB2_TEST_01A,DB2_TEST_02A db2pg

Using Graphical User Interface:

Select Storage ➤ Protection Groups ➤ '+' (plus sign)

See Figure 2.

db2_1.png

Figure 2

Select Storage ➤ Protection Group ➤ Protection Group ➤ '⋮' (vertical ellipses) ➤ Add Volumes...

See Figure 3.

db2_2.png    

 

 

 

 

 

 

 

Figure 3

Add volumes to the selected Protection Group.

Snapshot Volumes

Using Command Line Interface:

purepgroup snap pgroup

Using Graphical User Interface (GUI): 

Select Storage ➤ Protection Group ➤ '+' (plus sign)

See Figure 4.

db2_3.png

Figure 4

Create Volume from Snapshot

Using Command Line Interface:

List available snapshots for all or a specific volume.

purevol list --snap <volumes>

Example: 

purevol list --snap DB2_TEST_01A DB2_TEST_01B

Copy snapshot to a volume.

purevol copy --snap <source> <target>

Example:

purevol copy --snap pg1.DB2_TEST_01A TEST01A_FROM_SNAP

Using Graphical User Interface:

Select Storage ➤ Volumes ➤ Snapshots ➤ '' (vertical ellipses)

See Figure 5.

db2_4.png

Figure 5

Present (connect) copied volume(s) to the host.

purevol connect --host <host_name> <volume>

Example:

purevol connect --host HC-AIX87 TEST01A_FROM_SNAP

Using Graphical User Interface:

Select Storage ➤ Volumes ➤ Volume(name) ➤ '⋮' (vertical ellipses) ➤Connect Host

See Figure 6.

db2_5.png

Figure 6

Repeat the steps above for each volume containing table space containers.

AIX Target Host

Install DB2 Server

The DB2 Server must be installed on the target host before the the instance and database are created. For DB2 Server installation instructions see IBM Knowledge Center.

Create DB2 Instance

The DB2 instance must exist before the database is mounted on the target host. The basic command syntax and examples are provided below. For additional details and options consult IBM Knowledge Center

db2icrt -u FenceUser instance

Example:

db2icrt -u db2fenc1 db2inst1

Import and Configure Volume Group

The procedure outlined below shows how to import and configure volumes created from FlashArray snapshots. 

As root user, invoke configuration manager to configure new devices (LUNs).

cfgmgr -v

List physical volumes.

lspv

The example below shows hdisk10 and hdisk12 not belonging to any volume groups.

db2_6.png 

Import the volume group. Please note that importvg command requires only one physical volume to import the volume group. Any additional volume group physical volumes (members) will be automatically included by importvg command. Upon the successful import the volume group will be activated automatically.

importvg -y VolumeGroup PhysicalVolume

Example:

importvg -y vgdb2 hdisk10

Verify that all physical volumes have been included in the volume group.

lspv

The example below shows hdisk10 and hdisk12 belonging to vgdb2 volume group.

db2_8.png

Check volume group members.

lsvg -p VolumeGroup

Example:

lsvg -p vgdb2

db2_10.png

Check logical volumes.

lsvg -l VolumeGroup

Example:

lsvg -l vgdb2

The example below shows fslv00 logical volume and its /db2 mount point.

db2_9.png

Add the mount point and make the necessary entries to /etc/filesystems. This should now reflect the file system on the newly imported volume group and logical volume.

Example:

/db2:
        dev             = /dev/fslv00
        vfs             = jfs2
        log             = /dev/loglv00
        mount           = true
        check           = false
        options         = rw
        account         = false

Mount the logical volume.

Example:

mount /db2

If the instance owner user ID on the target is not the same instance owner user ID on the source system, it will be necessary to change the owner and group of the imported file system.

The <instance_home>/sqllib/db2nodes.cfg file may need to be modified to reflect the different hostname or IP address of the DB2 node. 

As an instance owner, start the database server (db2start) and catalog database.

db2 catalog database-name on drive

Example:

db2 catalog db tpcc on /db2/

Activate or connect to the database.

db2 activate database database-alias user username
db2 connect to database-alias user username

Example:

db2 connect to tpcc1 user db2inst1

For additional details regarding AIX and FlashArray refer to the FlashArray Cloning for IBM AIX Filesystem white paper.

Linux Target Host

Linux supports multiple file systems and logical volume management. While the use of Logical Volume Manager (LVM) is optional, two cases are described:

The DB2 Server installation and DB2 instance creation are identical regardless of the disk management method.

Install DB2 Server

The DB2 Server must be installed on the target host before the the instance and database are created. For DB2 Server installation instructions see IBM Knowledge Center.

Create DB2 Instance

The DB2 instance must exist before the database is mounted on the target host. The basic command syntax and examples are provided below. For additional details and options consult IBM Knowledge Center

db2icrt -u FenceUser instance

Example:

db2icrt -u db2fenc1 db2inst1

Direct Disk Management (no LVM)

As root user, invoke rescan-scsi-bus.sh script - see manual page (man rescan-scsi-bus.sh). This script is available as a part of sg3-utils package.

Example:

/usr/bin/rescan-scsi-bus.sh

Obtain the device name for the new disk.

fdisk -l

Example: 

db2_11.png

The new disk is /dev/sdb.

Create a mount point and mount the new disk (/dev/sdb).

Example:

mount /dev/sdb /tbs1

Optionally edit /etc/fstab to mount the new volume automatically upon the system boot.

If the instance owner user ID on the target is not the same instance owner user ID on the source system, it will be necessary to change the owner and group of the imported file system.

Logical Volume Management (LVM)

As user root invoke rescan-scsi-bus.sh script - see manual page (man rescan-scsi-bus.sh). This script is available as a part of sg3-utils package.

Example:

/usr/bin/rescan-scsi-bus.sh

Scan all disks using pvscan command. Depending on the Logical Volume Manager configuration the newly detected physical volumes and volume group may be automatically activated - see /etc/lvm/lvm.conf file.

db2_12.png

To show only active volume groups:

vgdisplay -A

db2_13.png

The <instance_home>/sqllib/db2nodes.cfg file may need to be modified to reflect the different hostname or IP address of the DB2 node. 

As an instance owner start the database server (db2start) and catalog database.

db2 catalog database-name on drive

Example:

db2 catalog db tpcc on /db2/

Activate or connect to the database.

db2 activate database database-alias user username
db2 connect to database-alias user username

Example:

db2 connect to tpcc1 user db2inst1

For additional details refer to Linux Recommended Settings and Configuring Linux DM-Multipath from scratch articles.

Conclusion

The ease of implementation, flexibility, efficiency, performance and simplicity of management make FlashArray and FlashArray-based snapshots an ideal choice for mission-critical, high-demand and high-availability environments with DB2. While the FlashArray snapshots are NOT a replacement for backup and archiving solutions, they provide simple, convenient and reliable means of protecting and duplicating data.


© 2018 Pure Storage, Inc. All rights reserved. Pure Storage, Pure1, and the Pure Storage Logo are trademarks or registered trademarks of Pure Storage, Inc. in the U.S. and other countries. Other company, product, or service names may be trademarks or service marks of their respective owners. The Pure Storage products described in this documentation are distributed under a license agreement restricting the use, copying, distribution, and decompilation/reverse engineering of the products. The Pure Storage products described in this documentation may only be used in accordance with the terms of the license agreement. No part of this documentation may be reproduced in any form by any means without prior written authorization from Pure Storage, Inc. and its licensors, if any. Pure Storage may make improvements and/or changes in the Pure Storage products and/or the programs described in this documentation at any time without notice.

THIS DOCUMENTATION IS PROVIDED "AS IS" AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. PURE STORAGE SHALL NOT BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH THE FURNISHING, PERFORMANCE, OR USE OF THIS DOCUMENTATION. THE INFORMATION CONTAINED IN THIS DOCUMENTATION IS SUBJECT TO CHANGE WITHOUT NOTICE.