DB2 Version 9 For Linux, UNIX, And Windows

Transcription

DB2 DB2 Version 9for Linux, UNIX, and WindowsData Recovery and High Availability Guide and ReferenceSC10-4228-00

DB2 DB2 Version 9for Linux, UNIX, and WindowsData Recovery and High Availability Guide and ReferenceSC10-4228-00

Before using this information and the product it supports, be sure to read the general information under Notices.Edition NoticeThis document contains proprietary information of IBM. It is provided under a license agreement and is protectedby copyright law. The information contained in this publication does not include any product warranties, and anystatements provided in this manual should not be interpreted as such.You can order IBM publications online or through your local IBM representative.v To order publications online, go to the IBM Publications Center at www.ibm.com/shop/publications/orderv To find your local IBM representative, go to the IBM Directory of Worldwide Contacts at www.ibm.com/planetwideTo order DB2 publications from DB2 Marketing and Sales in the United States or Canada, call 1-800-IBM-4YOU(426-4968).When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in anyway it believes appropriate without incurring any obligation to you. Copyright International Business Machines Corporation 2001, 2006. All rights reserved.US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contractwith IBM Corp.

ContentsAbout this book . . . . . . . . . . . viiWho should use this book .How this book is structured . vii. viiPart 1. Data recovery . . . . . . . . 1Chapter 1. Developing a good backupand recovery strategy . . . . . . . . . 3Developing a backup and recovery strategy . . . . 3Deciding how often to back up . . . . . . . . 6Storage considerations for recovery . . . . . . . 8Keeping related data together. . . . . . . . . 9Backup and restore operations between differentoperating systems and hardware platforms . . . . 9Crash recovery . . . . . . . . . . . . . 10Crash recovery - details . . . . . . . . . . 12Recovering damaged table spaces . . . . . . 12Recovering table spaces in recoverable databases 12Recovering table spaces in non-recoverabledatabases . . . . . . . . . . . . . . 13Reducing the impact of media failure . . . . . 14Reducing the impact of transaction failure . . . 16Recovering from transaction failures in apartitioned database environment . . . . . . 16Recovering from the failure of a databasepartition server . . . . . . . . . . . . 19Recovering indoubt transactions on the hostwhen DB2 Connect has the DB2 SyncpointManager configured . . . . . . . . . . 20Recovering indoubt transactions on the hostwhen DB2 Connect does not use the DB2Syncpoint Manager . . . . . . . . . . . 21Disaster recovery . . . . . . . . . . . . 22Version recovery . . . . . . . . . . . . . 23Rollforward recovery . . . . . . . . . . . 24Incremental backup and recovery . . . . . . . 27Incremental backup and recovery - details . . . . 28Restoring from incremental backup images . . . 28Limitations to automatic incremental restore . . 30Monitoring the progress of backup, restore andrecovery operations . . . . . . . . . . . . 32Understanding recovery logs . . . . . . . . 33Recovery log details . . . . . . . . . . . 35Log mirroring . . . . . . . . . . . . 35Reducing logging with the NOT LOGGEDINITIALLY parameter . . . . . . . . . . 36Configuration parameters for database logging37Configuring database logging options . . . . 45Log file management . . . . . . . . . . 46Log file allocation and removal . . . . . . . 48Log file management through log archiving . . 49Log archiving using db2tapemgr . . . . . . 51Archiving log files to tape . . . . . . . . 52Blocking transactions when the log directory fileis full . . . . . . . . . . . . . . . 53 Copyright IBM Corp. 2001, 2006On demand log archive . . . . . .Including log files with a backup image .How to prevent losing log files . . . .Understanding the recovery history file . .Recovery history file - garbage collection .Garbage collection . . . . . . . .Understanding table space states . . . .Enhancing recovery performance . . . .5454565658586061Chapter 2. Database backup . . . . . 63Backup overview . . . . . . . . . . . .Displaying backup information . . . . . . .Privileges, authorities, and authorization required touse backup . . . . . . . . . . . . . .Using backup . . . . . . . . . . . . . .Backing up to tape . . . . . . . . . . . .Backing up to named pipes . . . . . . . . .BACKUP DATABASE . . . . . . . . . . .db2Backup - Back up a database or table space . .Backup sessions - CLP examples . . . . . . .Optimizing backup performance . . . . . . .Automatic database backup . . . . . . . . .Enabling automatic backup . . . . . . . . .Compatibility of online backup and other utilitiesChapter 3. Database restore63656666687071768484858687. . . . . 89Restore overview . . . . . . . . . . . . 89Privileges, authorities, and authorization required touse restore . . . . . . . . . . . . . . . 90Using restore . . . . . . . . . . . . . . 90Using incremental restore in a test and productionenvironment . . . . . . . . . . . . . . 92Redefining table space containers during a restoreoperation (redirected restore) . . . . . . . . 94Restoring to an existing database . . . . . . . 95Restoring to a new database . . . . . . . . . 96Redefine table space containers by restoring adatabase using an automatically generated script . . 97Performing a redirected restore using anautomatically generated script . . . . . . . . 99RESTORE DATABASE . . . . . . . . . . 100db2Restore - Restore a database or table space . . 115Restore sessions - CLP examples . . . . . . . 127Optimizing restore performance . . . . . . . 129Database rebuild . . . . . . . . . . . . 130Rebuild - details . . . . . . . . . . . . 134Choosing a target image for database rebuild134Restrictions for database rebuild . . . . . . 137Rebuilding a database using selected table spaceimages . . . . . . . . . . . . . . 137Rebuilding selected table spaces . . . . . . 139Rebuilding a partitioned database . . . . . 140Rebuild and incremental backup images . . . 142Rebuild and table space containers . . . . . 143Rebuild and temporary table spaces . . . . . 144iii

Rebuild sessions - CLP examples . 145Chapter 4. Rollforward recovery . . . 155Rollforward overview . . . . . . . . .Privileges, authorities, and authorization requiredto use rollforward . . . . . . . . . . .Using rollforward . . . . . . . . . . .Rolling forward changes in a table space . . .Recovering a dropped table . . . . . . .Recovering data with the load copy location fileSynchronizing clocks in a partitioned databaseenvironment . . . . . . . . . . . . .Client/server timestamp conversion . . . . .ROLLFORWARD DATABASE. . . . . .db2Rollforward - Roll forward a database . . .Rollforward sessions - CLP examples . . . . 155.157157159163165.166167168177187Chapter 5. Database recover . . . . . 191Recover overview . . . . . . . . . . .Privileges, authorities, and authorization requiredto use recover . . . . . . . . . . . .Using recover . . . . . . . . . . . .Client/server timestamp conversion . . . . .RECOVER DATABASE . . . . . . . . .db2Recover - Restore and roll forward a database. 191.192192193193199Part 2. High availability . . . . . . 205Chapter 6. Introducing highavailability and failover support . . . 207High availability . . . . . . . . . . .High availability through log shipping . . . .High availability through online split mirror andsuspended I/O support . . . . . . . . .Online split mirror handling . . . . . . .Using a split mirror to clone a database . .Using a split mirror as a standby database .Using a split mirror as a backup image . . .Fault monitor facility for Linux and UNIX . . .db2fm - DB2 fault monitor . . . . . . . . 207. 209.210212212213214215219Chapter 7. High availability disasterrecovery (HADR) . . . . . . . . . . 221High availability disaster recovery overview . . .System requirements for high availability disasterrecovery (HADR) . . . . . . . . . . . .Installation and storage requirements for highavailability disaster recovery . . . . . . . .Restrictions for high availability disaster recovery(HADR) . . . . . . . . . . . . . . .Standby database states in high availability disasterrecovery (HADR) . . . . . . . . . . . .Synchronization modes for high availabilitydisaster recovery (HADR) . . . . . . . . .Replicated operations for high availability disasterrecovery (HADR) . . . . . . . . . . . .Non-replicated operations for high availabilitydisaster recovery (HADR) . . . . . . . . .ivHigh availability disaster recovery (HADR)commands overview . . . . . . . . . . .High availability disaster recovery (HADR)management . . . . . . . . . . . . .Initializing high availability disaster recovery(HADR) . . . . . . . . . . . . . . .START HADR . . . . . . . . . . . . .db2HADRStart - Start high availability disasterrecovery (HADR) operations . . . . . . . .Stopping high availability disaster recovery(HADR) . . . . . . . . . . . . . . .STOP HADR . . . . . . . . . . . . .db2HADRStop - Stop high availability disasterrecovery (HADR) operations . . . . . . . .Database configuration for high availabilitydisaster recovery (HADR) . . . . . . . . .Database activation and deactivation in highavailability disaster recovery (HADR) . . . . .Automatic client reroute and high availabilitydisaster recovery (HADR) . . . . . . . . .Index logging and high availability disasterrecovery (HADR) . . . . . . . . . . . .Log archiving configuration for high availabilitydisaster recovery (HADR) . . . . . . . . .Cluster managers and high availability disasterrecovery (HADR) . . . . . . . . . . . .Switching database roles in high availabilitydisaster recovery (HADR) . . . . . . . . .Performing an HADR failover operation . . . .TAKEOVER HADR . . . . . . . . . . .db2HADRTakeover - Instruct a database to takeover as the high availability disaster recovery(HADR) primary database . . . . . . . . .Reintegrating a database after a takeover operationPerforming a rolling upgrade in a high availabilitydisaster recovery environment . . . . . . . .Monitoring high availability disaster recovery(HADR) . . . . . . . . . . . . . . .High availability disaster recovery (HADR)performance . . . . . . . . . . . . . 64266268269270271Chapter 8. Cluster support on AIX . . 275High Availability Cluster Multi-Processing support 275221Chapter 9. Cluster support on theWindows operating system . . . . . 281222Microsoft Cluster Server support .224Chapter 10. Cluster support for theSolaris Operating Environment . . . . 285226Cluster support for the Solaris operating systemSun Cluster 3.0 support . . . . . . . . .VERITAS Cluster Server support . . . . . .226229232233Data Recovery and High Availability Guide and Reference. 281285. 287. 290Part 3. Appendixes . . . . . . . . 295Appendix A. How to read the syntaxdiagrams . . . . . . . . . . . . . 297

Appendix B. Warning, error andcompletion messages . . . . . . . . 301Appendix C. Additional DB2commands . . . . . . . . . . . . 303 System commands. . . . . . . . . . .db2adutl - Managing DB2 objects within TSMdb2ckbkp - Check backup . . . . . . .db2ckrst - Check incremental restore imagesequence . . . . . . . . . . . . .db2flsn - Find log sequence number . . .db2inidb - Initialize a mirrored database . .db2mscs - Set up Windows failover utility .db2rfpen - Reset rollforward pending state .CLP commands . . . . . . . . . . .ARCHIVE LOG . . . . . . . . . .INITIALIZE TAPE . . . . . . . . .LIST HISTORY. . . . . . . . . .PRUNE HISTORY/LOGFILE . . . . . .REWIND TAPE . . . . . . . . . .SET TAPE POSITION . . . . . . . .UPDATE HISTORY . . . . . . . . . 303303. x D. Additional APIs andassociated data structures . . . . . 335db2ArchiveLog - Archive the active log file . .db2HistoryCloseScan - End the history file scandb2HistoryGetEntry - Get the next entry in thehistory file . . . . . . . . . . . . .db2HistoryOpenScan - Start a history file scan .db2HistoryUpdate - Update a history file entry .db2Prune - Delete the history file entries or logfiles from the active log path . . . . . . .db2ReadLogNoConn - Read the database logswithout a database connection . . . . . . .db2ReadLogNoConnInit - Initialize reading thedatabase logs without a database connection . .db2ReadLogNoConnTerm - Terminate reading thedatabase logs without a database connection . .db2ReadLog - Extracts log records . . . . .db2HistoryData . . . . . . . . . . .SQLU LSN . . . . . . . . . . . . . 335337. 338. 341. 345. 348. 350. 353.355356360366Appendix H. Tivoli Space ManagerHierarchical Storage Managementsupport for partitioned tables . . . . 407Appendix I. User exit for databaserecovery . . . . . . . . . . . . . 409Sample user exit programs .Calling format . . . . .Error handling . . . . . 409. 410. 411Appendix J. Backup and restore APIsfor vendor products . . . . . . . . 413DB2 APIs for backup and restore to storagemanagers . . . . . . . . . . . . . .Operational overview . . . . . . . .Operational hints and tips . . . . . . .Invoking a backup or a restore operation usingvendor products . . . . . . . . . .sqluvint - Initialize and link to a vendor devicesqluvget - Read data from a vendor device . .sqluvput - Write data to a vendor device . . .sqluvend - Unlink a vendor device and release itsresources . . . . . . . . . . . . . .sqluvdel - Delete committed session . . . . .db2VendorQueryApiVersion - Get the supportedlevel of the vendor storage API . . . . . .db2VendorGetNextObj - Get next object on deviceDB2 info. . . . . . . . . . . . .Vendor info. . . . . . . . . . . .Init input . . . . . . . . . . . . .Init output . . . . . . . . . . . . .Data . . . . . . . . . . . . . . .Return code . . . . . . . . . . . .APIs for compressed back

PRUNE HISTORY/LOGFILE. 329 REWIND TAPE . 330 SET TAPE POSITION. 331 UPDATE HISTORY. 332 Appendix D. Additional APIs and associated data structures. 335 db2ArchiveLog-Archive the active log file. 335 db2HistoryCloseScan-End the history file scan 337 db2HistoryGetEntry-Get the next entry in the history file. 338 db2HistoryOpenScan-Start a history file scan. 341 db2HistoryUpdate-Update a history