Roll forward session-CLP sample
The Rollforward DATABASE command allows multiple operations to be specified each time, and each operation is separated by a keyword AND . For example, to roll forward to the end of the log, and then finish, you can use the following stand-alone commands:
DB2 Rollforward DB sample to end of logs DB2 Rollforward DB sample complete
Combinations are:
DB2 Rollforward DB sample to end of logs and complete
Although the two methods are equivalent, it is recommended that you take two steps to complete this type of operation. It is important to verify that it has the expected progress before stopping the roll-forward operation to avoid losing any logs.
If the roll forward command encounters an error, the roll forward operation cannot be completed. In this case, the error is returned so that you can fix the error and re-issue the above command. However, if the error cannot be corrected, you can force roll-forward completion by issuing the following command:
DB2 Rollforward DB Sample complete
This command brings the database online and reverts to the pre-failure log point.
Example 2
Roll the database forward to the end of the log (two table spaces restored):
DB2 Rollforward DB sample to end of logs DB2 Rollforward DB sample to end of logs and stop
The two statements are equivalent. You do not need an and STOP or complete table space to roll forward to the end of the log. The tablespace name is not required. If not specified, all table spaces that require roll-forward recovery will be included. If only a subset of these table spaces will be rolled forward, you must specify their names.
Example 3
Once you have restored 3 tablespace, roll one forward to the end of the log and the other two roll forward to a point in time, and all operations are performed online:
DB2 Rollforward DB sample to end of logs tablespace (TBS1) online DB2 rollforward DB sample to 1998-04-03-14.21.56 and St Op tablespace (TBS2, TBS3) online
It should be noted that two roll forward operations cannot run concurrently. The second command can be called only after the first roll-forward operation has been successfully completed.
Example 4
After the database is restored, roll forward to a point in time and use OVERFLOW log PATH to specify the directory where the user exits to hold the archived logs:
DB2 Rollforward DB Sample to 1998-04-03-14.21.56 and stop overflow log path (/logs)
Example 5
In the following example, there is a database called Sample. Back up the database, include the recovery log in the backup image, restore the database, and then roll forward the database to the end of the backup timestamp.
Back up the database and include the recovery log in the backup image:
DB2 backup DB sample online include logs
Use a backup image to restore the database:
DB2 Restore DB Sample
Roll the database forward to the end of the backup timestamp:
DB2 Rollforward DB Sample to end of backup
Example 6 (partitioned database environment)
There are three database partitions: 0, 1, and 2. Define tablespace TBS1 on all database partitions, and define tablespace TBS2 on database partitions 0 and 2. After you have restored the database on database partition 1 and restored TBS1 on database partitions 0 and 2, roll forward the database in database partition 1:
DB2 Rollforward DB sample to end of logs and stop
This returns warning SQL1271 (the database has been recovered, but one or more tablespaces on database partitions 0 and 2 are offline).
DB2 Rollforward DB sample to end of logs
This command rolls forward TBS1 in database partitions 0 and 2. In this case, the clause tablespace (TBS1) is optional.
Example 7 (partitioned database environment)
In the following example, there is a partitioned database called Sample. Use a single-system view backup to back up all database partitions, restore the database on all database partitions, and roll forward the database to the end of the backup timestamp.
Perform a single system view (SSV) Backup:
DB2 backup DB sample on all nodes online include logs
To restore the database on all database partitions:
Db2_all "DB2 restore DB Sample taken at 1998-04-03-14.21.56"
Roll the database forward to the end of the backup timestamp:
DB2 Rollforward DB Sample to end of the backup on all nodes
Example 8 (partitioned database environment)
In the following example, there is a partitioned database called Sample. Use Db2_all to back up all database partitions with one command, restore the database on all database partitions, and roll forward the database to the end of the backup timestamp.
Use Db2_all to back up all database partitions with one command:
Db2_all "DB2 backup DB sample include Logs to/shared/dir/"
To restore the database on all database partitions:
Db2_all "DB2 Restore DB Sample from/shared/dir/"
Roll the database forward to the end of the backup timestamp:
DB2 Rollforward DB Sample to end of the backup on all nodes
Example 9 (partitioned database environment)
After the tablespace TBS1 is restored on database partitions 0 and 2 only, roll forward TBS1 in database partitions 0 and 2:
DB2 Rollforward DB sample to end of logs
Database partition 1 is ignored.
DB2 Rollforward DB sample to end of logs tablespace (TBS1)
This command failed because TBS1 is not ready to roll forward recovery on database partition 1. Report sql4906n.
DB2 Rollforward DB Sample to end of the logs on Dbpartitionnums (0, 2) tablespace (TBS1)
Completed successfully.
DB2 Rollforward DB Sample to 1998-04-03-14.21.56 and stop tablespace (TBS1)
This command failed because TBS1 is not ready to roll forward recovery on database partition 1; All segments must be rolled forward together.
Note: the DBPARTITIONNUM clause is not accepted after the tablespace is rolled forward to a point in time. The roll forward operation must be performed on all the database partitions on which the tablespace resides.
After restoring TBS1 on database partition 1:
DB2 Rollforward DB Sample to 1998-04-03-14.21.56 and stop tablespace (TBS1)
Completed successfully.
Example 10 (partitioned database environment)
The table space is rolled back to PIT2, but not specified, when the tablespace is restored on all database partitions AND STOP . The roll forward operation is still in progress. Cancel and roll forward to PIT1:
DB2 Rollforward DB Sample to Pit2 tablespace (TBS1) DB2 Rollforward DB sample Cancel Tablespace (TBS1) * * Restore TBS1 on all dbpartitionnums * * DB2 rollforward DB sample to Pit1 tablespace (TBS1) DB2 rollforward DB Sample Stop tab Lespace (TBS1)
Example 11 (Partitioned database environment)
The db2nodes.cfg table spaces on the 8 database partitions (3 to 10) listed in the roll-forward recovery file are as follows:
DB2 Rollforward database Dwtest to end of logs tablespace (TSSPRODT)
A roll-forward recovery to the end of the log (instead of a point-in-time) completes successfully. You do not have to specify the database partition where the tablespace resides. Utility defaults to db2nodes.cfg file.
Example 12 (partitioned database environment)
Roll forward restores 6 small tablespaces on a single database partitioned database partition group (on database partition 6):
DB2 Rollforward database Dwtest to end of logs on Dbpartitionnum (6) tablespace (Tsstore, Tssbuyer, Tsstime, TSS Whse, Tsslscat, Tssvendor)
A roll-forward recovery to the end of the log (instead of a point-in-time) completes successfully.
Example 13 (partition table-roll forward to the end of the log on all data partitions)
Partitioned tables, indexed in TBSP0, are created using tablespace tbsp1, TBSP2, and TBSP3. Later, the user adds a data partition to the table in TBSP4 and joins the data partition from the table in the TBSP5. All table spaces can be rolled forward to the end of the log.
DB2 Rollforward DB Pbardb to END of LOGS and stop tablespace (TBSP0, Tbsp1, TBSP2, TBSP3, TBSP4, TBSP5)
Completed successfully.
Example 14 (partition table-roll forward to the end of a log in a table space)
Partitioned tables were originally created using Tablespace tbsp1, TBSP2, and TBSP3, indexed in TBSP0. Later, the user adds a data partition to the table in TBSP4 and joins the data partition from the table in the TBSP5. The tablespace TBSP4 is corrupted and requires resiliency and roll forward to the end of the log.
DB2 Rollforward DB Pbardb to END of LOGS and Stop tablespace (TBSP4)
Completed successfully.
Example 15 (partitioned table-roll up to a point in time on all data partitions, including those that have been added, connected, detached, or indexed)
Partitioned tables, indexed in TBSP0, are created using tablespace tbsp1, TBSP2, and TBSP3. Later, the user adds a data partition to the table in TBSP4, joins the data partition from the table in the TBSP5, and splits the data partition from the TBSP1. The user performs a roll-forward to the PIT operation on all tablespaces used by the partitioned table, including those specified in the INDEX in clause.
DB2 Rollforward DB Pbardb to 2005-08-05-05.58.53 and stop tablespace (TBSP0, Tbsp1, TBSP2, TBSP3, TBSP4, TBSP5)
Completed successfully.
Example 16 (partition table-roll forward to PIT in a small number of table spaces)
Partitioned tables were created using three tablespace (TBSP1, TBSP2, and TBSP3). Later, the user detached all data partitions from the TBSP3. Only the TBSP1 and tbsp2 are allowed to roll forward to the PIT.
DB2 Rollforward DB Pbardb to 2005-08-05-06.02.42 and stop tablespace (TBSP1, TBSP2)
This article is from the "arvin_0213" blog, make sure to keep this source http://arvin0213.blog.51cto.com/2455782/1929595
DB2 Roll Forward session