Recovery Concepts

March 22, 2018 | Author: senlife | Category: Databases, Ibm Db2, Backup, Directory (Computing), Database Transaction


Comments



Description

Database Recovery Using Redirected Incremental RestoreRoman Melnyk (mailto:[email protected]), Senior Member of the DB2 Information Development team, IBM Toronto Lab Summary: How do you recover your database to a new server when no full backup image representing the current state of the database exists? This article gives you a strategy for recovery from disaster. Tag this! Update My dW interests (Log in | What's this?) Skip to help for Update My dW interests Date: 05 Dec 2002 Level: Introductory Activity: 1943 views Comments: 2 (View | Add comment - Sign in) Average rating (7 votes) Rate this article © 2002 International Business Machines Corporation. All rights reserved. This article is written for IBM® DB2® Universal DatabaseTM for Linux, UNIX®, and Windows® In a previous article (DB2 Basics: Cloning DB2 Databases Using Redirected Restore), I outlined the precise steps that you need to take to restore a DB2 database on a different machine, using a redirected restore operation. A redirected restore operation consists of a two-step database restore process with an intervening table space container definition step. This is a great way to clone a database using a full database backup image. But what about the case in which a database must be restored on a different server, but no full backup image representing the current state of the database exists? Suppose your database server is destroyed by fire. Luckily, you have a good backup strategy in place. This strategy includes remote storage of backup images and recovery logs. The set of backup images that you have at your disposal includes full database backup, online incremental backup, and online incremental delta backup images. Your database is enabled for rollforward recovery (the logretain database configuration parameter is set to ON) and incremental backup (the trackmod database configuration parameter is set to ON), and you have the logs that contain any transactions that occurred during and after the last backup operation. backup_type>\<instance_name>\<node_number>\<catalog_node_number>\<da > Inside this subdirectory tree. transactions that are not part of any database backup image (but that are recorded in the recovery logs) are reapplied against the database following the successful completion of required database restore operations. An incremental backup image contains all changes made since the last full backup operation. see the article Using DB2 Incremental Backup. and the image is located in D:\SAMPLE.0) representing the actual backup image. An incremental delta backup image contains all changes made since the last backup operation. and then create a full database backup image: set DB2INSTANCE=PROD db2start db2sampl db2 update db cfg for sample using logretain on db2 update db cfg for sample using trackmod on db2 backup db sample The timestamp for this image is 20021022205203. 1. followed by a database rollforward operation. DB2 creates this subdirectory tree off of the directory from which the BACKUP DATABASE command is issued. and the details are identical.To recover this database on another server. The principle is the same. Create the SAMPLE database on PROD. During a database rollforward operation. A redirected incremental restore operation is a redirected restore operation that is applied to a set of incremental backup images. The source instance in this example is called PROD. The target instance is called MYINST. you will have to carry out a redirected incremental database restore operation. For more information about incremental backup operations. We are going to use the SAMPLE database that ships with DB2. Instead of restoring backup images from another server. The file name represents the time at which the backup was taken. enable it for rollforward recovery and incremental backup. The subdirectory names represent the following: <database_alias. there will be a file (205203. The following (Windows) example shows you exactly how to successfully perform a redirected incremental restore and rollforward operation. The SAMPLE database in this case will be created on drive D. be it full or incremental. . I will show you how to recover a database from a different instance.0\PROD\NODE0000\CATN0000\20021022. There are now three backup images inside the subdirectory tree (full. There are now two backup images inside the subdirectory tree.2) insert into sales values ('10/31/2002'.7) connect reset We will need the transaction logs. Connect to the SAMPLE database and apply some more transactions against the SALES table: db2 db2 db2 db2 db2 connect to sample insert into sales values ('10/31/2002'.'GOUNOT'.'GOUNOT'.3) insert into sales values ('10/23/2002'. and incremental delta). as well as the backup images. Connect to the SAMPLE database and apply additional transactions against the SALES table. 4. (An online backup operation permits concurrent database access by other applications. 2.5) insert into sales values ('10/28/2002'.'LEE'.2) backup db sample online incremental The timestamp for this image is 20021022205237.'Ontario-North'. If necessary. then invoke an online incremental backup operation.1) backup db sample online incremental delta The timestamp for this image is 20021022205302.'LUCCHESSI'. to recover the SAMPLE database on MYINST. verify the location of these logs: .'LEE'.'Manitoba'.'LUCCHESSI'.) db2 db2 db2 db2 db2 db2 connect to sample insert into sales values ('10/21/2002'.'Ontario-South'. incremental. 3.4) insert into sales values ('10/25/2002'.'LUCCHESSI'.'Ontario-South'.'Ontario-South'.7) insert into sales values ('10/24/2002'.'Quebec'.'Quebec'.'GOUNOT'.'GOUNOT'. Connect to the SAMPLE database and apply some transactions against one of its tables (SALES.Note: If you were relocating the backup image to another machine. Invoke an online incremental delta backup operation: db2 db2 db2 db2 connect to sample insert into sales values ('10/28/2002'.'Manitoba'. create the above path on the target machine (substituting the appropriate target instance name for PROD) and copy the backup image to that directory.9) insert into sales values ('10/31/2002'. for example).'Ontario-North'. and USERSPACE1): db2 set tablespace containers for 0 using (path 'd:\ts0con1') db2 set tablespace containers for 1 using (path 'd:\ts1con1') db2 set tablespace containers for 2 using (path 'd:\ts2con1') You can use the LIST TABLESPACES SHOW DETAIL command to get information about all of the table spaces in the source database. you do not have to issue a separate RESTORE DATABASE command for every backup image in the set of images (full and incremental) required to restore the database. this will help you ensure that containers have been set for all of the table spaces in the target database. 7. If you specify AUTOMATIC.db2 get db cfg for sample Output from this command includes the path to the log files. TEMPSPACE1. 5. Complete the redirected restore operation: db2 restore db sample continue The database is in rollforward pending state. . set DB2INSTANCE=MYINST db2start db2 restore db sample incremental automatic from d taken at 20021022205302 to d redirect The FROM parameter must be specified if the RESTORE DATABASE command is invoked from a directory other than the one that contains the backup image. The TO parameter specifies the target database directory (only the drive letter is specified on Windows operating systems). 6. Start MYINST and then invoke the first step of a redirected restore operation. Define new table space containers for the three default table spaces that are associated with the restored database (SYSCATSPACE. and must be rolled forward before it can be accessed. 9. and Blair Adamache. and copy the logs from the SAMPLE database on PROD to this location: db2 get db cfg for sample copy PROD\NODE0000\SQL00001\SQLOGDIR\*. see David Kline's article Production to Development: Moving Databases.8. that the table space containers that you have defined for it are in fact associated with the restored database. • . Complete the database recovery operation by rolling the transaction logs forward to capture all changes made to the database after the last backup operation: db2 rollforward db sample to end of logs and stop 10.* D:\MYINST\NODE0000\SQL00002\SQLOGDIR Output from the GET DATABASE CONFIGURATION command includes the path to the log files. see the article Using DB2 Incremental Backup by Miro Flasza. Dale McInnis. and that all of the transactions against the SAMPLE database on PROD are reflected in the recovered database on MYINST: db2 list db directory db2 connect to sample db2 list tablespace containers for 0 db2 list tablespace containers for 1 db2 list tablespace containers for 2 db2 select * from sales db2 connect reset db2 terminate db2stop set DB2INSTANCE=PROD db2stop Resources • Incremental backup and restore. DB2 backup and restore operations. Verify that the restored database has been cataloged properly. Determine the log path for the SAMPLE database on MYINST. .D. Roman has written numerous DB2 books and other related materials. 2000). see the article DB2 Redirected Restore Scripts by Mark Mulligan. 2001). 2001). . Redirected restore scripts in an AIX® environment. You can reach him at roman_b_melnyk@hotmail. is a senior member of the DB2 Information Development team. Melnyk. DB2 Fundamentals Certification for Dummies (Hungry Minds. During more than eight years at IBM. Roman recently coauthored DB2: The Complete Reference (Osborne/McGraw-Hill. and DB2 for Dummies (IDG Books.• Redirected restore operations. Melnyk . specializing in database administration and DB2 utilities. see DB2 Basics: Cloning DB2 Databases Using Redirected Restore by Roman B. Ph.com . • About the author Roman B. A redirected restore operation consists of a two-step database restore process with an intervening table space container definition step: 1. UNIX®. unless the file systems and the physical devices that are referenced by the database on the source system are set up exactly the same way on the target system. IBM Toronto Summary: This article gives you the basics of cloning a DB2 for Linux. Tags for this article: cloning. This article is written for IBM® DB2® Universal DatabaseTM for Linux. replication Tag this! Update My dW interests (Log in | What's this?) Skip to help for Update My dW interests Date: 31 Oct 2002 Level: Introductory Also available in: Korean Activity: 18580 views Comments: 0 (View | Add comment .) . All rights reserved. duplication. Issue the RESTORE DATABASE command with the REDIRECT option.Sign in) Average rating (69 votes) Rate this article © 2002 International Business Machines Corporation. or Windows database. UNIX. If you want to clone a database from one machine to another. 2. Therefore. db2. Staff Information Development. Use the SET TABLESPACE CONTAINERS command to define table space containers for the restored database (DB2 needs to know where you want the table spaces to reside on the target system.com). and Windows® A database restore operation uses a database backup image to recreate a database. luw. you will need to perform a redirected restore operation. The file system paths used by the database are also contained within the backup image. the simplest way is to restore the database from a backup image.DB2 Basics: Cloning DB2 Databases Using Redirected Restore Roman Melnyk (roman_b_melnyk@hotmail. I will show you how to restore a backup image from a different instance. The following example shows you exactly how to successfully perform a redirected restore operation on Windows operating systems or on UNIX-based systems. The target instance is called MYINST. . Issue the RESTORE DATABASE command again.0) representing the actual backup image. One way to ensure that this does not happen is to create and run a script that contains all three parts of the redirected restore procedure.0\PROD\NODE0000\CATN0000\20030909.backup_type>\<instance_name>\<node_number>\ <catalog_node_number>\<date> Inside this subdirectory tree. In the UNIX example. the image is located in D:\MOVIES. SQL0900N is returned and the restore operation fails. Instead of restoring a backup image from another server. It is important to remember that the entire redirected restore operation must be invoked from the same session. otherwise. On Windows. this time specifying the CONTINUE option. The source instance for the UNIX example is called prod. The source instance for the Windows example is called PROD. The MOVIES database is located on drive D. The existing database on PROD that is going to be restored (created) on MYINST is called MOVIES. the image is located in /home/prod. there will be a file (143225. 1. On Windows. ensure that the current instance is PROD: set DB2INSTANCE=PROD db2start db2 backup db movies The timestamp for this image is 20030909143225. the subdirectory names represent the following: <database_alias. The principle is the same. The target instance is called myinst. DB2 creates this subdirectory tree off the directory from which the BACKUP DATABASE command is issued.3. Before issuing the BACKUP DATABASE command on Windows. and the details are identical. Create a full database backup image of the MOVIES database. The file name represents the time at which the backup was taken. On Windows.<timestamp>.001 The components of that name represent the following: <database_alias>.prod. <catalog_node_number>. On Windows. Define new table space containers for the three default table spaces that are associated with the restored database (SYSCATSPACE. the actual backup image is named as follows: MOVIES.Note: If you were relocating the backup image to another machine.<backup_type>.0.<instance_name>.0) to that directory.NODE0000. In the UNIX example. TEMPSPACE1. issue the following command while logged in as myinst: db2 restore db movies from /home/prod taken at 20030909143225 redirect 3.CATN0000.<sequence_number> 2. You can also use compression tools to package the backup image while maintaining the directory tree for transport. create the above path on the target machine (substituting the appropriate target instance name for PROD) and copy the backup image (in this case 143225. and USERSPACE1).20030909143225.<node_number>. issue: db2 set tablespace containers for 0 using (path 'd:\tsc_movies\ts0con1') db2 set tablespace containers for 1 using (path 'd:\tsc_movies\ts1con1') db2 set tablespace containers for 2 using (path 'd:\tsc_movies\ts2con1') . set DB2INSTANCE=MYINST db2start db2 restore db movies from d taken at 20030909143225 redirect The FROM parameter must be specified if the RESTORE DATABASE command is invoked from a directory other than the one that contains the backup image. On the UNIX-based system. start MYINST and then invoke the first step of a redirected restore operation. Version 8 About the author . Complete the redirected restore operation: db2 restore db movies continue 5. 4.On the UNIX-based system. Verify that the restored database has been cataloged properly. issue: db2 "set tablespace containers for 0 using (path 'ts0con1')" db2 "set tablespace containers for 1 using (path 'ts1con1')" db2 "set tablespace containers for 2 using (path 'ts2con1')" You can use the LIST TABLESPACES SHOW DETAIL command to get information about all of the table spaces in the source database. this will help you ensure that containers have been set for all of the table spaces in the target database. and that the table space containers that you have defined for it are in fact associated with the restored database: db2 list db directory db2 connect to movies db2 list tablespace containers for 0 db2 list tablespace containers for 1 db2 list tablespace containers for 2 db2 connect reset db2 terminate db2stop Resources • • David Kline's article: Production to Development: Moving Databases IBM DB2 Universal Database Data Recovery and High Availability Guide and Reference. specializing in database administration. During more than eleven years at IBM. is a senior member of the DB2 Information Development team.D. . and DB2 for Dummies. Roman recently edited Apache Derby -. articles. Melnyk . DB2: The Complete Reference. Roman coauthored DB2 Version 8: The Official Guide. DB2 utilities.Off to the Races..Roman B. and SQL. and other related materials. Roman has written and edited numerous DB2 books. Ph. DB2 Fundamentals Certification for Dummies.
Copyright © 2024 DOKUMEN.SITE Inc.