an ibm db2 dba’s guide to actifio copy data managementdocs.actifio.com/8.1/pdfs/dbadb2.pdf ·...
TRANSCRIPT
Copyright, Trademarks, and other Legal Matter
Copyright © 2009 - 2018 Actifio, Inc. All rights reserved.
Actifio®, AnyIT®, Dedup Async®, OnVault®, Enterprise Data-as-a-Service®, FlashScan®, AppFlash DEVOPS Platform®, Copy Data Cloud®, and VDP® are registered trademarks of Actifio, Inc.
Actifio Sky™, Actifio One™, and Virtual Data Pipeline™ are trademarks of Actifio, Inc.
All other brands, product names, goods and/or services mentioned herein are trademarks or property of their respective owners.
Actifio, Inc., is a provider of data protection and availability products. Actifio’s technology is used in products sold by the company and products and services sold and offered by its commercial partners. The current list of Actifio patents is available online at: http://www.actifio.com/patents/
Actifio believes the information in this publication is accurate as of its publication date. Actifio reserves the right to make changes to information published in this document, including without limitation specifications and product descriptions, at any time and without notice. This document supersedes and replaces all information supplied prior to the publication hereof.
THE INFORMATION IN THIS PUBLICATION IS PROVIDED “AS IS.” ACTIFIO, INC. MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WITH RESPECT TO THE INFORMATION IN THIS PUBLICATION, AND SPECIFICALLY DISCLAIMS IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
This software and the associated documentation are proprietary and confidential to Actifio. Use, copying, and distribution of any Actifio software described in this publication requires an applicable software license. Any unauthorized use or reproduction of this software and the documentation may be subject to civil and/or criminal liability.
Actifio strives to produce quality documentation and welcomes your feedback. Please send comments and suggestions to [email protected].
ii | actifio.com |IBM Db2 DBA’s Guide to Actifio Copy Data Management
Contents
The ActifioNOW Customer Portal.....................................................................................................................3
Actifio Support Centers ....................................................................................................................................3
Chapter 1 - Introducing Actifio Copy Data Management for IBM Db2 Databases .............. 1
Chapter 2 - Preparing Db2 LUW Servers and Databases in a Unix-Linux Environment ....... 3
Chapter 3 - Protecting a Db2 LUW Database ........................................................................... 5
Protecting a Db2 Database ...............................................................................................................................5
Protecting Database Archivelog Purging when Archive Log is Protected as a File System........................9
Chapter 4 - Accessing and Recovering a Db2 LUW Database .............................................. 11
Clone a Copy of a Db2 Database to a Specified Target.................................................................................12
Restore/Recover a Db2 Database Back to the Production Server................................................................14
Cleaning up Mounted Images for Db2 ..........................................................................................................15
| actifio.com | MySQL DBA’s Guide to Actifio Copy Data Management 1
|
Preface
The information presented in this guide is intended for users who are familiar with basic Actifio processes and procedures as described in Getting Started with Actifio Copy Data Management and who are qualified to administer IBM Db2 databases.
Your Actifio appliance’s Documentation Library contains detailed, step-by-step, application-specific instructions on how to protect and access your data. Each guide is in PDF format and may be viewed online, downloaded, or printed on demand. The following guides will be of particular interest:
• Connecting Hosts to Actifio Appliances
• Virtualizing and Protecting Copy Data with the Application Manager
• Accessing and Recovering Copy Data with the Application Manager
• Restoring Copy Data with the Application Manager
The ActifioNOW Customer PortalDuring the configuration and initialization of your Actifio appliance your Actifio representative provided you with a user name and password for the ActifioNOW customer portal.
From the customer portal you can obtain detailed reports about your Actifio appliance as well as search the portal’s knowledge base for answers to specific questions.
To log into the ActifioNOW customer portal:
1. Go to: https://now.actifio.com
2. When prompted, enter the user name and password provided by your Actifio representative.
Actifio Support CentersTo contact an Actifio support representative, you can:
• Send email to: [email protected]
• Call:
From anywhere: +1.315.261.7501
US Toll-Free: +1.855.392.6810
Australia: 0011 800-16165656
Germany: 00 800-16165656
New Zealand: 00 800-16165656
UK: 0 800-0155019
actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 3
1
|
Introducing Actifio Copy Data Management for IBM Db2 Databases
Db2 with Actifio Out-of-Band Linux CBT
Supported OS Versions
• Red Hat Enterprise Linux: RHEL 6.5, 6.6, 6.8 update1, RHEL 7.0, 7.1, 7.2, 7.3
• SuSE Linux: SLES 11 sp3, 11 sp4, SLES 12, SLES 12.1
Operation Benefit
Backup Manual and/or scheduled online backups (incremental-forever full snapshots)
Recovery Recovery of a database to its most recent state, a specific point in time of snapshots
Recovery to the original host or an alternate host
Test/Dev Copy Migration of Db2 from a physical to a virtualized environment
Multiple point in time copies and instant Test/Dev refresh
Accelerate and automate Test/Dev provisioning
Backup Catalog view Actifio Desktop
actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 1
2
|
Preparing Db2 LUW Servers and Databases in a Unix-Linux Environment
Db2 is a is a family of relational database management system within IBM's Information Management division that is centered on several relational database management system offerings. This article explains how to protect Db2 application consistent database data with Actifio Sky in a Linux environment.
Prerequisites
Protected database storage path (storage path + database directory path + active log path+ archive log path) must be on LVM and the protected volume must not be the boot volume.
If the multiple database under Db2 instance are sharing the same file system, then all the Linux logical volume that are part of the file system must be protected under one generic application.
Identify the LUNs
Use the commands below to get database data LUN paths.
To get the LUNs for the storage path:
#db2pd -db <database name> -storagepath
To get the LUNs for the container path:
#db2pd -db <database name> -tablespaces
To get the LUNs for the database directory path:
#db2 list db directory#db2 "SELECT DBPARTITIONNUM, SUBSTR(TYPE,1,15) AS TYPE, SUBSTR(PATH,1,35) as DB_STORAGE_PATH FROM SYSIBMADM.DBPATHS"#db2 get db cfg for <Primary database name> show detail | | grep -i path
To get the LUNs for the archivelog path:
#db2 get db cfg for <Primary-dbname> show detail | grep -i log
Protection of Db2 LUW from primary instance
• Database must be in Archive log mode, not in Circular mode.
To check if the database is in Circular or Archive log mode, run the command
#"db2 get db cfg for <Primary database name>| grep LOGARCHMETH1"
If the database is in Circular mode then change the logging to Archive mode.
• Make sure the path is on LVM:
Run df -h to get the mapping of the filesystem to the device mapper devices.
Run lvs command to map the device mapper device names to LV name and VG name.
Make a note of the LV and VG names which will need to be protected.
actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 3
4
On the Db2 Server Host
• Install the Actifio Connector on the Db2 server host (see Connecting Hosts to Actifio Appliances.)
• Enable Linux change block tracking on the database server from the Actifio Desktop > Domain Manager > Host > Details:
Enabling Linux CBT for the Db2 Server
| actifio.com |IBM Db2 DBA’s Guide to Actifio Copy Data Management
3
|
Protecting a Db2 LUW Database
This includes:
Protecting a Db2 Database on page 5
Protecting Database Archivelog Purging when Archive Log is Protected as a File System on page 9
Protecting a Db2 DatabaseTo protect a Db2 database:
1. Begin by creating an application for the LUNs to be protected. Open the Actifio Desktop to the Application Manager.
2. Select the APP tab, and from the service menu select New Application.
3. Create a new generic application and assign VDisks:
4. On "Add An Application" page:
a. Select Out-of-Band band type.
b. Enter an application name for the database protection under "Enter Application Name"
actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 5
6
c. Under "Select Host" select the database host name.
d. Under "Select Logical Volumes" select the logical volumes to be protected by double clicking the "+" sign in left pane. The selected volumes will show in right hand pane.
e. Under "Generic LVM Script Name" enter the name of the Script name which will be used for quiescing the database. This script is required to be under /act/scripts. You can use template script "/act/act_scripts/genericlvm/db2/genlvmscript.sh"
f. Refer to section 7 "Scripts setup"
5. Set up the scripts
a. Login to database server as root.
b. cd to /act (cd /act)
c. Create an /act/scripts directory if not there:
mkdir scriptscd /act/scripts
6. Create log directory under /act/scripts:
mkdir -p /act/scripts/logchmod 755 /act/scripts/log
7. Copy script from "/act/act_scripts/genericlvm/db2 " to /act/scripts folder:
cp "/act/act_scripts/genericlvm/db2 / /act/scripts
This contains 5 scripts:
appid.xxxxxfreeze.xxxxthaw.xxxxxinvoke_db2_act_func.shact_pre_post.sh
8. Get the applicationid for the created generic application. From Application Manager, mouse over and get the application id. The application id in this example is 1996369.
9. Modify “xxxx” with the appid extension. From the command line:
cp -p freeze.xxxx freeze.1996369cp -p thaw.xxxxx thaw.1996369
10. Modify freeze.1996369 and thaw.1996369 for instance name , database name option.
| actifio.com |IBM Db2 DBA’s Guide to Actifio Copy Data Management
In freeze.1996369
To set write suspend of all database for all db2 instances running on this server, uncomment the line:
$PWDS/invoke_db2_act_func.sh -u root -o SUSPEND
Other lines (below) remain commented.
#$PWDS/invoke_db2_act_func.sh -u root -i db2inst2 -o SUSPEND ' use this option for write suspend of all databases under one instance#$PWDS/invoke_db2_act_func.sh -u root -i db2inst2 -d actprod -o SUSPEND ' use this option for write suspend of one database under one instance
To set write suspend of all database for one db2 instances running on this server, uncomment the line:
$PWDS/invoke_db2_act_func.sh -u root -i <db2inst2> -o SUSPEND
Modify < db2inst2> with appropriate db2 instance name.
Other lines (below) remain commented.
#$PWDS/invoke_db2_act_func.sh -u root -o SUSPEND ----' default#$PWDS/invoke_db2_act_func.sh -u root -i db2inst2 -d actprod -o SUSPEND ' use this option for write suspend of one database under one instance
To set write suspend of one database for any instances running on this server, uncomment the line:
$PWDS/invoke_db2_act_func.sh -u root -i <db2inst2> -d <actprod> -o SUSPEND
Modify < db2inst2> and <actprod> with appropriate db2 instance name and database name.
Other lines (below) remain commented.
#$PWDS/invoke_db2_act_func.sh -u root -o SUSPEND ----' default#$PWDS/invoke_db2_act_func.sh -u root -i db2inst2 -o SUSPEND ' use this option for write suspend of all databases under one instance
In thaw.1996369
To set write resume of all database for all db2 instances running on this server, uncomment the line:
$PWDS/invoke_db2_act_func.sh -u root -o RESUME
Other lines (below) remain commented.
#$PWDS/invoke_db2_act_func.sh -u root -i db2inst2 - RESUME ' use this option for write suspend of all databases under one instance#$PWDS/invoke_db2_act_func.sh -u root -i db2inst2 -d actprod -o RESUME ' use this option for write suspend of one database under one instance
To set write suspend of all database for one db2 instances running on this server, uncomment the line:
$PWDS/invoke_db2_act_func.sh -u root -i <db2inst2> -o RESUME
Modify < db2inst2> with appropriate db2 instance name.
Other lines (below) remain commented.
#$PWDS/invoke_db2_act_func.sh -u root -o RESUME ----' default#$PWDS/invoke_db2_act_func.sh -u root -i db2inst2 -d actprod -o RESUME ' use this option for write suspend of one database under one instance
To set write suspend of one database for any instances running on this server, uncomment the line:
$PWDS/invoke_db2_act_func.sh -u root -i <db2inst2> -d <actprod> -o RESUME
Modify < db2inst2> and <actprod> with appropriate db2 instance name and database name.
Other lines (below) remain commented.
| actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 7
8
#$PWDS/invoke_db2_act_func.sh -u root -o RESUME ----' default#$PWDS/invoke_db2_act_func.sh -u root -i db2inst2 -o RESUME ' use this option for write suspend of all databases under one instance
| actifio.com |IBM Db2 DBA’s Guide to Actifio Copy Data Management
Protecting Database Archivelog Purging when Archive Log is Protected as a File System
Setup Steps
1. Configure the purge scripts.
2. Login to database server as root.
3. cd to /act/scripts.
4. Create copy of appid.xxxx, thaw.xxxxx.
5. Get the applicationid for the protected file system application. From the Application Manager, mouse over and get the application id.
The application id in above example is 1996369
6. Modify "xxxx" with "1996369" extension
From the command line
cp -p appid.xxxx appid.1996369cp -p thaw.xxxxx thaw.1996369
7. Modify thaw.1996369 for username, instancename, database name option.
The option that can be set here:
In thaw.1996369
Script Usage
-u <root or db2 instance owner>, i <db2instance>,-d <database>,-o prune
Uncomment the appropriate "PRUNE" statement in thaw script.
| actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 9
10
Parameter settings under act_pre_post.sh
Archivelog parameters that can be adjusted
dblog_retn=7 (default): This is the parameter for retention of output logs of act_pre_post.sh in the /act/scripts/log directory
logretention=30 (default): This is parameter related to purging of archive logs within the LOGARCHMETH1 path, so if the logretention=30 is set then it will remove archive logs above 30 days from LOGARCHMETH1 path.
Parameter that can be adjusted to set the parallel operation to run the write suspend or write resume or archive purging in parellelparallel
max_simul_inst_call_ctr=5 (default): This parameter is to control how many simultaneous database instances can we do the write suspend or write resume or purge of archive logs in parallel
max_simul_db_call_ctr=10 (default): This parameter is to control how many databases in one instance we have to do a write suspend or write resume or purge of archive logs in parallel
for example if max_simul_db_call_ctr=10 then the scripts will do a parallel write suspend or write resume or purge of archive logs for 10 databases at atime, If there are more than 10 databases then the scripts will start a second loop.
Parameter settings under invoke_db2_act_func.sh
Parameter that can be adjusted to keep the logs file of freeze and thaw output:
SCRLOG_RETN=7 (default): This is the parameter for retention of output logs of invoke_db2_act_fucn.sh in the /act/scripts/log directory.
Objective PRUNE statement
When the script is running as root OS user (i.e. under Domain Manager the logging credentials are provided for root):
To purge the archivelog of all databases for all instances on the database server
#$PWDS/invoke_db2_act_func.sh -u root -o PRUNE
To purge the archivelog of all databases under one instance
#$PWDS/invoke_db2_act_func.sh -u root -i <db2instance> -o PRUNE
To purge the archivelog of one database under one instance
#$PWDS/invoke_db2_act_func.sh -u root -i <db2 instance name> -d <database name> -o PRUNE
When the script is running as db2 instance owner (i.e. under Domain Manager the logging credentials are provided for the Db2 instance owner)
To purge the archivelog of all databases under one instance
#$PWDS/invoke_db2_act_func.sh -u <db2 instance owner> -i <db2 instance name> -o PRUNE
To purge the archivelog of one database under one instance
#$PWDS/invoke_db2_act_func.sh -u <db2instance owner> -i <db2instance> -d <database> -o PRUNE
| actifio.com |IBM Db2 DBA’s Guide to Actifio Copy Data Management
4
|
Accessing and Recovering a Db2 LUW Database
Use Cases:
Clone a Copy of a Db2 Database to a Specified Target on page 12
Restore/Recover a Db2 Database Back to the Production Server on page 14
Cleaning up Mounted Images for Db2 on page 15.
Prerequisites
To restore back to production or to clone to a new target:
Create existing meta data information and backup to a backup location.
LOG_DIR= <Existing Old Active Log Path>STORAGE_PATH=<Existing Old Storage Path 1>STORAGE_PATH=<Existing Old Storage Path 2>.....CONT_PATH= <Existing Old Container Path 1>CONT_PATH= <Existing Old Container Path 2>.....FAILARCHIVE_PATH=<Existing Old Directory Path>LOGARCHMETH1=<Existing Old Directory Path>LOGARCHMETH2=<Existing Old Directory Path>MIRRORLOG_PATH=<Existing Old Directory Path>OVERFLOWLOG_PATH=<Existing Old Directory Path
For cloning to new target the target DB2 instance name needs to be same as protected DB2 instance name. In case of no instance on target server, a new DB2 instance will need to be created with the same name as source before clone operation.
actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 11
12
Clone a Copy of a Db2 Database to a Specified Target1. Make sure the source and target Db2 database version and fix pack upgrades are same and the instance is
up and running.
2. Mount the image from protected app for the database to the target server.
Manual step after the mount job is complete:
a. On target host get the mapping file of the LVMs under /act/mountmaps/<Mount_Job_Name>_<Application Name>
Mapping format is: < Backed up Volume>:<Mounted volume>
For example:
testvg/tinylv-1:/dev/acttestvgtinylv-1_1456776222571_1456776252400/act_staging_voltestvg/tinylv-2:/dev/acttestvgtinylv-2_1456776225282_1456776262989/act_staging_vol
b. Mount each of the mapped volume to appropriate mount points
For example:
mount /dev/acttestvgtinylv-1_1456776222571_1456776252400/act_staging_vol </db2data>mount /dev/acttestvgtinylv-2_1456776225282_1456776262989/act_staging_vol </db2log>
3. Login as root and modify the mounted file system owner and group to Db2 OS owner and group:
For example:
# id db2inst1uid=502(db2inst1) gid=505(db2inst1) groups=505(db2inst1), 502(dasadm1)# chown -R db2inst1: db2inst1 /DBMOUNTPOINT# chown -R db2inst1: db2inst1 /LOGMOUNTPOINT
4. Copy the Archive logs to the Active log path (without over writing any existing Active logs). cd to the active log directory and then:
cp -n -p <Archive log directory>/*.LOG
5. Catalog the database from the mounted file system:
db2 "catalog database <Source database name> on /< Mounted file system>/<Database directory>"
6. Create the configuration file relocatedb.cfg as needed. Refer to your Db2 LUW documentation for more details on the parameters specified in the example below:
For example: vi relocatedb.cfg
DB_NAME= <Source Database Name>DB_PATH= <OLD DB Path>, <New DB Path>INSTANCE= <Instance Name> NODENUM=<Node Number>LOG_DIR= <Old Active Log Path>, <New Active Log Path>STORAGE_PATH= <Old Storage Path 1>, <New Storage Path 1>STORAGE_PATH= <Old Storage Path 2>, <New Storage Path 2>……….FAILARCHIVE_PATH= <New Directory Path>LOGARCHMETH1= <New Directory Path>LOGARCHMETH2= <New Directory Path>MIRRORLOG_PATH= <New Directory Path>OVERFLOWLOG_PATH= <New Directory Path>……….
7. Run db2inidb using relocate option:
| actifio.com |IBM Db2 DBA’s Guide to Actifio Copy Data Management
db2inidb <source database name> as standby relocate using relocatedb.cfg
8. Query the database to make sure that the database is in rollforward db pending state:
db2 "rollforward db <database name> query status"
9. Roll forward the database to a point in time:
db2 "rollforward db <source database name> to yyyy-mn-dd-hh.mi.ss using local time"
10. Query the database to make sure that the database is in rollforward db pending state:
db2 "rollforward db <database name> query status"
11. Complete the recovery:
db2 "rollforward db <source database name> complete"
12. Create a new configuration file to rename the database:
Ex: vi relocate_dbnm.cfgDB_NAME=<Old database name>, <New database name>DB_PATH=<DB_PATH>INSTANCE=<Instance Name>NODENUM=<Node Number>
13. Run the db2relocatedb command using the relocate_dbnm.cfg file:
db2relocatedb -f relocate_dbnm.cfg
14. Connect to the new database:
db2 connect to <new database name>
15. Proceed to Cleaning up Mounted Images for Db2 on page 15.
| actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 13
14
Restore/Recover a Db2 Database Back to the Production Server To restore a Db2 database back to its original production server:
1. Log in as the db2 owner: (su - <db2 OS owner>)
2. Stop the running instance: (db2stop)
a. Clean any Db2 resources running: (ipclean )
b. Unmounts the filesystem
3. From Actifio Desktop perform restore for the protected generic app:
a. Start the Db2 instance (db2start)
b. Run db2inidb with standby option:
db2inidb <database-name> as standby
c. Check the status of the database:
db2 "rollforward db <database-name> query status"
d. Rollforward to end of logs
db2 "rollforward db <database-name> to end of logs"
e. Query to see the status of the database:
db2 "rollforward db <database-name> query status"
f. Rollforward database to stop and activate the database
db2 "rollforward db <database-name> stop"
g. Connect to the database (db2 connect to <database-name>)
4. Proceed to Cleaning up Mounted Images for Db2 on page 15.
| actifio.com |IBM Db2 DBA’s Guide to Actifio Copy Data Management
Cleaning up Mounted Images for Db2For all databases
1. Log in as the Db2 owner:
su - <db2 OS owner>
2. Execute:
db2 connect to <database name> db2 force application all db2 terminate db2 deactivate db <database name>
3. Log in to Actifio Desktop and Unmount & Delete the mounted image:
| actifio.com | IBM Db2 DBA’s Guide to Actifio Copy Data Management 15