Administration Guide
Roll-forward recovery using the BACKUP command in conjunction with the
RESTORE and ROLLFORWARD commands puts the database or table space in a state
that has been previously saved.
When you first create a database, only
circular logging is enabled for it. This means that logs are re-used
(in a circular fashion), and are not saved or archived. With circular
logging, roll-forward recovery is not possible: only crash recovery or
version recovery is enabled. When log archiving is performed, however,
roll-forward recovery is possible, because the logs record changes to the
database after the time that the backup was taken. You perform log
archiving by activating either (or both) of the logretain and
userexit database configuration parameters. When either of
these parameters are enabled, the database is enabled for roll-forward
recovery.
When the database is recoverable, you can perform backup, restore, and
roll-forward recovery at both the database and the table space level.
The backups of the database and table space can be online. Online
restore and rollforward are also available at the table space
level.
Roll-forward recovery re-applies the completed units of work recorded in
the logs to the restored database, table space, or table spaces. You
can specify that roll-forward recovery is to the end of the logs, or to a
particular point in time.
Roll-forward recovery can follow the completion of a full database restore
as described in "Restoring a Database". It can also be done with table spaces that are in a roll-forward
pending state. For considerations on rolling forward a table space, see
"Rolling Forward Changes in a Table Space"
For more information about the database configuration parameters associated
with logging, see "Configuration Parameters for Database Logging".
Following are the backup considerations that apply when your database is
enabled for forward recovery. For general information that applies to
performing backups, refer to the following:
- Roll-forward recovery is not enabled by the default setting ("Off")
of the logretain and userexit configuration
parameters. The default for both parameters is set to "Off"
because, initially, there is no backup that you can use to recover the
database; initially, the database cannot be recovered, so you cannot
perform forward recovery on it.
To enable a new database for roll-forward recovery, you must enable at
least one of these configuration parameters before taking the first backup of
the database. When you change the value of one or both parameters, the
database will be put into the backup pending state, which requires
that you take an offline backup of the database. After the backup
operation completes successfully, the database can be used.
- You cannot back up a database that is not in a usable state except for a
database in the backup pending state.
- If a database or a table space is in a partially restored state due to a
system crash during any stage of restoring the database, you must successfully
restore the database or the table space before you can back it up.
- If any of the table spaces in a database is in an "abnormal" state,
you cannot back up the database or that table space, unless it is in the
backup pending state.
- You can back up a database or table space to a fixed disk, a tape, or a
location managed by ADSM or another vendor storage management product.
See "ADSTAR Distributed Storage Manager" for information on ADSM.
Under OS/2, you can also back up to diskette or to a user exit.
- If your database is enabled for roll-forward recovery and you are using a
tape system that does not support the ability to uniquely reference a backup,
it is recommended that you do not keep multiple backup copies of the same
database on the same tape.
- Multiple files may be created to contain the backed up data from the
database or table space.
In OS/2, when you restore from a user exit and roll forward the database,
the path to the database is the only reference used to locate the
containers. Therefore, all the containers for that database that are on
the backup tape are restored.
- To reduce the amount of time required to complete a backup:
- Use table space backups.
You can back up (and subsequently recover) part of a database by using the
TABLESPACE option of the BACKUP command. This makes administering data,
index, and long fields/large objects (LOBs) in separate table spaces
easier.
- Increase the value of the PARALLELISM parameter so that it reflects the
number of table spaces that are being backed up.
- The considerations for backing up table spaces are as follows:
- A table space backup and a table space restore cannot be run at the same
time, even if the backup and restore are working on different table
spaces.
- If you have tables that span more than one table space, you should backup
(and restore) the set of table spaces together.
- If each table space is on a different disk, a media error only affects a
particular table space, not the entire database. The table space with
the error is placed in a roll-forward pending state. You can still use
the other table spaces in the database, unless the table space in this state
has the system catalog tables. In this situation, you cannot connect to
the database.
- The system catalog table space can be restored independent of the rest of
the database if a table-space level backup containing the system catalog table
space is available.
- The backup will fail if a list of the table spaces to be backed up
contains a temporary table space.
- The considerations for a partitioned database environment are as
follows:
If you want to be able to do forward recovery, you must regularly back up
the database on the list of nodes, and you must have at least one backup of
the rest of the nodes in the system (even those that do not contain user data
for that database). Two situations require the backed-up image of a
database partition at a database partition server that does not contain user
data for the database:
- You added a database partition server to the database system after taking
the last backup, and you need to do forward recovery on this database
partition server.
- Point-in-time recovery is used, which requires that all database
partitions in the system are in the roll-forward pending state.
The recovery history file is updated automatically with summary information
whenever you carry out a backup or restore of a full database or table
space. This file can be a useful tracking mechanism for restore
activity within a database. This file is created in the same directory
as the database configuration file. For more information on the
recovery history file, see "Recovery History File Information".
In UNIX-based environments, the file name(s) created on disk will consist
of a concatenation of the following information, separated by periods; on
other platforms a four-level subdirectory tree is used:
- Database alias
- A 1-to-8 character database alias name that was supplied when the backup
command was invoked.
- Type
- Type of backup taken, where: "0" is for full database, "3"
is for table space, and "4" is for copy from a table load.
- Instance name
- A 1-to-8 character name of the current instance of the database manager
that is taken from the DB2INSTANCE environment variable.
- Node number
- The node number.
- Catalog node number
- The node number of the database's catalog node.
- Time stamp
- A 14-character representation of the date and time the backup was
performed. The timestamp is in the format yyyymmddhhnnss,
where:
yyyy is the year (1995 to 9999)
mm is the month (01 to 12)
dd is the day of the month (01 to 31)
hh is the hour (00 to 23)
nn is the minutes (00 to 59)
ss is the seconds (00 to 59)
- Sequence number
- A 3-digit sequence number used as a file extension.
Following are the restore considerations that apply when your database is
enabled for forward recovery. For general information that applies to
performing restores, refer to the following:
- You can restore a backup copy of a full database backup or table space
backup to an existing database. To restore to an existing database, you
must have SYSADM, SYSCTRL, or SYSMAINT authority. The backup image may
differ from the existing database in its alias name, its database name, or its
database seed.
- When you restore to an existing database, and the database seeds are the
same, the logs are retained.
- You can only use the RESTORE command if the database or table space has
been previously backed up with the BACKUP command.
- A database enabled for roll-forward recovery must be rolled forward after
it is restored, otherwise it will be in the roll-forward pending state, and
will be unusable. (The exception occurs when a restore WITHOUT
ROLLFORWARD is specified.) You cannot turn roll-forward off if the
backup is taken online or if the backup is taken at the table space
level.
- The backup copy of the database or table space to be used by the RESTORE
command can be located on a fixed disk, a tape or a location managed by the
ADSTAR* Distributed Storage Manager (ADSM) utility or another vendor
storage management product. See "ADSTAR Distributed Storage Manager" for information on ADSM.
If you use ADSM and do not specify the TAKEN AT parameter, ADSM retrieves
the latest backup copy.
Under OS/2, the backup copy of the database or table space could also be
located on diskette or through a user exit.
Under Windows 95 and Windows NT, the backup copy of the database or table
space could also be located on diskette.
- While restore and roll-forward are independent operations, your recovery
strategy may have restore as the first phase of a complete roll-forward
recovery of a database. After a successful restore, a database that was
configured for roll-forward recovery at the time the backup was taken enters a
roll-forward pending state, and is not usable until the ROLLFORWARD command
has been run successfully.
When the ROLLFORWARD command is issued:
- If the database is in the roll-forward pending state, the database is
rolled forward.
- If the database is not in the roll-forward pending state, but table spaces
in the database are, when you issue the ROLLFORWARD command and specify a list
of table spaces, only those table spaces are rolled forward. If you do
not specify a list, all table spaces that are in the roll-forward pending
state are rolled forward.
Another database RESTORE is not allowed when the roll-forward process is
running.
Notes:
- If you are restoring from a full database backup that was created using
the offline option of the BACKUP command, you can bypass this
roll-forward pending state during the restore process. Using the
WITHOUT ROLLING FORWARD option allows you to use the restored database
immediately without rolling forward the database.
- If you are restoring from a backup that was created using the
online option of the BACKUP command, you cannot bypass
this roll-forward pending state.
- The considerations for restoring table spaces are as follows:
- You can only restore a table space if the table space currently exists,
and it is the same table space. (The "same table space" means that
the table space was not dropped and re-created between taking the backup image
and the attempt to restore the table space.)
- You cannot restore a table space backup to a new database.
- If you backed up tables that spanned more than one table space, you should
restore the set of table spaces together.
- Once the RESTORE command starts for a table space backup, the table space
is not usable until the RESTORE command followed by a roll-forward recovery
completes successfully.
- A table space restore can be online (share mode) or offline (exclusive
mode).
- If a system failure occurs during the restoring of a table space backup,
only the table space being restored is unusable. The other table spaces
in the database can still be used.
- You cannot perform an online table space restore of the system catalog
tables.
- When doing a partial or subset RESTORE, you can use either a table space
backup, or a full database backup and choose one or more table spaces from
that image. All the log files associated with the table space (or table
spaces) must exist from the time the backup was created.
In a partitioned database system, if you intend to roll forward a table
space (or table spaces) to the end of the logs, you do not have to restore it
at each database partition (node). You only need to restore it at the
database partitions that require recovery. If you intend to roll
forward a table space to a point in time, you must restore the table space at
each database partition before rolling forward.
- In OS/2, a partial or subset restore is not possible when restoring from a
user exit.
- The considerations for redirected restore are as follows:
- During a backup of a database or one or more table spaces, a record is
kept of all the table space containers in use by the table spaces that are
backed up. During a RESTORE, all containers listed in the backup are
checked to see if they currently exist and are accessible. If one or
more of the containers is inaccessible because of a media failure (or for any
other reason), the RESTORE will fail. To allow a restore in such a
case, the redirecting of table space containers is supported during
the RESTORE. This support includes adding, changing, or removing of
table space containers.
- A RESTORE is often followed by a ROLLFORWARD to reapply changes recorded
in the database logs after the point in time where the backup was
taken. During a roll-forward operation, you may re-execute or re-run a
transaction which carries out an ALTER TABLESPACE with the ADD
option (to add a container). For the ROLLFORWARD to be successful, the
container to be added must be accessible. If the container is not
accessible, then the roll-forward for the table space is suspended, and the
table space is left in a roll-forward pending state.
- You may or may not wish to re-do the add container operations in the
database logs. In fact, you may not know which containers may have been
added since the backup was taken. Therefore, you cannot anticipate
which containers are needed. Alternatively, depending on why you are
performing a redirected restore, you may simply prefer the list of containers
you specified at the time of the restore, and do not want any other containers
added. To control this behavior, you can indicate at the time of the
restore whether you want the ROLLFORWARD to re-create the containers during
the roll-forward recovery. (You can edit the list of table space
containers on the CONTAINERS - CHANGE window of the Restore Database or
Restore Table Space notebook in the Control Center.)
Roll-forward recovery builds on a restored database and allows you to restore
a database to a particular time that is after the time that the database
backup was taken. This point can be either the end of the logs, or a
point between the time of the database backup and the end of the logs.
You might use point-in-time recovery if an active or an archived log is not
available. In this situation, you could roll forward to the point where
the log is missing. You might also roll forward to a point in time if a
bad transaction was run against the database. In this situation, you
would restore the database, then roll forward to just before the time that the
bad transaction was run.
Figure 31. Roll-Forward Recovery
You can also perform point-in-time roll-forward recovery on table
spaces. For additional information, see "Rolling Forward Changes in a Table Space".
To use this method, the database must be configured to enable roll-forward
recovery. Considerations for the database configuration file and
database logs are presented in the following topics:
If you have tables that contain DATALINK columns, also see "Restoring Databases and Table Spaces and Rolling Forward to the End of the Logs" and "Restoring Databases and Table Spaces and Rolling Forward to a Point in Time".
The database configuration file contains parameters related to roll-forward
recovery. The default parameters do not support this recovery, so if
you plan to use it, you need to change some of these defaults. For
additional information, see Chapter 20. "Configuring DB2".
- Primary logs (logprimary)
- This parameter specifies the number of primary logs that will be
created.
A primary log, whether empty or full, requires the same amount of disk
space. Thus, if you configure more logs than you need, you use disk
space unnecessarily. If you configure too few logs, you can encounter a
log-full condition. As you select the number of logs to configure, you
must consider the size you make each log and whether your application can
handle a log-full condition.
If you are enabling an existing database for roll-forward recovery, change
the number of primary logs to the sum of the number of primary and secondary
logs, plus 1. Additional information is logged for long
varchar and LOB fields in a database enabled for roll-forward
recovery.
- Secondary logs (logsecond)
- This parameter specifies the number of secondary log files that are
created and used for recovery log files (only as needed).
When the primary log files become full, the secondary log files (of size
logfilsiz) are allocated one at a time as needed, up to a maximum
number as controlled by this parameter. An error code will be returned
to the application, and activity against the database will be stopped, if more
secondary log files are required than are allowed by this parameter.
See "Number of Secondary Log Files (logsecond)" for recommendations on how to use secondary logs.
- Log size (logfilsiz)
- This parameter determines the number of pages for each of the configured
logs. A page is 4KB in size.
The size of each primary log has a direct bearing on performance.
When the database is configured to retain logs, each time a log is filled, a
request is issued for allocation and initialization of a new log.
Increasing the size of the log reduces the number of requests required to
allocate and initialize new logs. (Keep in mind, however, that with a
larger log size it takes more time to format each new log). The
formatting of new logs is transparent to applications connected to the
database so that database performance is unaffected by formatting.
Assuming that you have an application that keeps the database open to
minimize the processing time to open a database (see "Recovery Performance Considerations"), the value for the log size should be determined by the amount of time it
takes to make offline archived log copies.
The data transfer speed of the device you use to store offline archived
logs, and the software used to make the copies, must at a minimum match the
average rate at which the database manager writes data in the logs. If
the transfer speed cannot keep up with new log data being generated, you may
run out of disk space if logging activity continues for a sufficiently long
period of time, determined by the amount of free disk space. If this
happens, database processing will stop.
The data transfer speed is most significant when using tape or some optical
medium. (Refer to Appendix L. "User Exit for Database Recovery" for information on using different media for storing logs.) Some tape
devices require the same amount of time to copy a file, regardless of its
size. You must determine the capability of your archiving
device.
Additionally, tape devices have some unique considerations. The
frequency of the archiving request is important. If the time for any
copy operation is five minutes, the log size should be large enough to hold
five minutes of log data during your peak work load. Also, the tape
device may have design limits that restrict the number of operations per
day. These factors must be considered when you determine the log
size.
Minimizing log file loss is also an important consideration in setting the
log size. Archiving takes an entire log. If you use a single
large log, you increase the time between archiving. If the medium
containing the log fails, some transaction information will probably be
lost. Decreasing the log size increases the frequency of archiving but
can reduce the amount of information loss in case of a media failure since the
smaller logs before the one lost can be used.
- Log Buffer (logbufsz)
- This parameter allows you to specify the amount of database shared memory
to use as a buffer for log records before writing these records to
disk. The log records are written to disk when one of the following
occurs:
- A transaction commits
- The log buffer is full
- As a result of some other internal database manager event.
Buffering the log records will result in more efficient logging file I/O,
because the log records will be written to disk less frequently and more log
records will be written at each time.
- Number of Commits to Group (mincommit)
- This parameter allows you to delay the writing of log records to disk
until a minimum number of commits have been performed. This delay can
help reduce the database manager overhead associated with writing log records
and, as a result, improve performance when you have multiple applications
running against a database and many commits are requested by the applications
within a very short time frame.
This grouping of commits will only occur when the value of this parameter
is greater than 1, and when the number of applications connected to the
database is greater than the value of this parameter. When commit
grouping is being performed, application commit requests are held until the
earlier of either one second elapsing or the number of commit requests equals
the value of this parameter.
- New log path (newlogpath)
- The database logs are initially created in SQLOGDIR, which is a
subdirectory of the database directory. You can change the location
where active logs and future archive logs are placed by changing the value for
this configuration parameter to point to either a different directory, or to a
device. Archive logs that are currently stored in the database log path
directory are not moved to the new location if the database is configured for
roll-forward recovery.
Because you can change the log path location, the logs needed for
roll-forward recovery may exist in different directories or on different
devices. You can change this configuration parameter during the
roll-forward process to allow you to access logs in multiple locations.
The change to the value of newlogpath will not be applied until
the database is in a consistent state. A database configuration
parameter indicates the status of the database. See "Database is Consistent (database_consistent)" for additional information about this status indicator. See "Considerations for Managing Log Files" for information about the roles database logs play if a database is not in
a consistent state.
- Log retain (logretain)
- This parameter causes archived logs to be kept in the database log path
directory. Enabling it allows the database manager to use the
roll-forward recovery method. You do not require userexit to
be enabled when the logretain configuration parameter is
enabled. Either one of the two parameters is sufficient to allow the
roll-forward recovery method.
Using this parameter means that the circular logging, that is the default,
is being overridden.
- User exit (userexit)
- This parameter causes the database manager to call a user exit program for
archiving and retrieving logs. With the user exit enabled, roll-forward
recovery is allowed. You do not require logretain to be
enabled when the userexit configuration parameter is
enabled. Either one of the two parameters is sufficient to allow the
roll-forward recovery method.
Using this parameter means that the circular logging, that is the default,
is being overridden. Userexit implies logretain
but the reverse is not true.
See Appendix L. "User Exit for Database Recovery", for information about the user exit program.
The active log path is important when using either the userexit
configuration parameter or the logretain configuration parameter to
allow roll-forward recovery. When the userexit configuration
parameter is set, the user exit is called to archive log files away from the
active log path. When the logretain configuration parameter
is set, this ensures that the log files remain in the active log path.
The active log path is determined either by the Path to Log Files or Changed
Path to Log Files (newlogpath).
If the database is enabled for forward recovery, you have the option of
backing up, restoring, and rolling forward table spaces instead of using the
entire database. You may want to implement a recovery strategy for
individual table spaces because this can save time: it takes less time
to recover a portion of the database than it does to recover the entire
database. For example, if a disk is bad and it only contains one table
space, the table space can be restored and rolled forward without having to
recover the entire database (and without impacting user access to the rest of
the database). Also, table-space-level backups allow you to back up
critical portions of the database more frequently than other portions, which
requires less time than backing up the entire database.
If, in a partitioned database environment, some database partitions are in
the roll-forward pending state, and, on other database partitions, some table
spaces are in the roll-forward pending state (but the database partition is
not), you must first roll forward the database partitions, then roll forward
the table spaces.
If the data and long objects of a table are in separate table spaces, and
the table has been reorganized, the table spaces for both the data and long
objects must be restored and rolled forward together. You should take a
back up of the affected table spaces after the table is reorganized.
Different states are associated with a table space to indicate its current
status:
After a table space is restored, it is always in the roll-forward pending
state (that is, if you restore a table space and specify the WITHOUT ROLLING
FORWARD parameter, the WITHOUT ROLLING FORWARD is ignored). To make the
table space usable, you must perform roll-forward recovery on it. You
have the option of rolling forward to the end of the logs, or rolling forward
to a point in time. If you want to roll forward a table space to a
point in time, you should be aware of the following:
- You cannot roll forward system catalog tables to a point in time.
These must be rolled forward to the end of the logs to ensure that all table
spaces in the database remain consistent.
- A table space that is to be rolled forward to a point in time must have
been restored from a backup that is earlier than the point in time specified
for the roll forward.
- If you do not want to roll the table space forward, you can specify
ROLLFORWARD STOP, which is the same as rolling the table space forward to the
time of the restored backup.
Note: | You cannot do this if the backup image was taken online. In this
situation you must roll forward to at least the end of the backup.
|
- If you are rolling forward to a point in time, and a table is contained in
multiple table spaces, all table spaces that contain the table must be rolled
forward simultaneously. If, for example, the table data is contained in
one table space, and the index for the table is contained in another table
space, you must roll forward both table spaces simultaneously to the same
point in time.
- Before rolling forward a table space, use the LIST TABLESPACES SHOW DETAIL
command. This command returns information on the "Minimum Recover
Time", which is the earliest point in time to which the table space can be
rolled forward. The minimum recovery time is updated when DDL
statements are executed against the table space, or against tables in the
table space. The table space must be rolled forward to at least the
minimum recovery time so that is synchronized with the information in the
system catalog tables.
Because the recovered table space must be consistent with the system
catalog tables, you cannot perform a table space roll forward to recover a
dropped table space or table, because the catalog table will indicate that the
object was previously dropped. This means that you should not create
dummy tables in those table spaces that you want to recover separately from
the database.
- You can issue QUIESCE TABLESPACES FOR TABLE to create a
transaction-consistent point in time that you can use for rolling forward
table spaces. When you quiesce table spaces for a table (in share,
intent to update or exclusive), the request will wait (through locking) for
all running transactions that are accessing objects in the table spaces to
complete while blocking new requests against the table spaces. When the
quiesce request is granted, all outstanding transactions are already completed
(committed or rolled back) and the table spaces are in a consistent
state. You can look in the recovery history file to find quiesce points
and check whether they are past the minimum recovery time to determine a
desirable time to stop the roll forward.
- If you want to roll forward a table space to a point in time and a table
in the table space participates in a referential integrity relationship with
another table that is contained in another table space, you should roll
forward both table spaces simultaneously to the same point in time. If
you do not, both table spaces will be in the check pending state at the end of
the point-in-time roll forward operation. If you roll forward both
table spaces at the same time, the constraint will remain active at the end of
the point-in-time roll forward operation.
- If you want to roll forward a table space to a point in time and a table
in the table space is either of the following:
- An underlying table for a summary table that is in another table space
- A summary table for a table in another table space
You should roll forward both table spaces to the same point in
time. If you do not, the summary table is placed in the check
pending state at the end of the roll-forward operation.
- You should be careful that a point-in-time table space roll forward
operation does not cause a transaction to be rolled back in some table spaces,
and committed in others. This can happen when:
- Point-in-time roll forward is performed on a subset of the table spaces
that were updated by a transaction, and the point in time is before the time
that the transaction committed.
- Any table contained in the table space being rolled forward to a point in
time has an associated trigger, or is updated by a trigger that affects table
spaces other than the one that is being rolled forward.
You should find a point in time to stop rolling forward that will prevent
this from happening.
- After a table space point-in-time roll forward operation completes, the
table space (or table spaces) is placed in the backup pending state.
You must take a backup of the table space because all updates made to it
between the point in time that you rolled forward to and the current time have
been removed. You can no longer roll forward the table space to the
current time from a previous database or table space backup. The
following example shows why the table space backup is required, and how it is
used. (To make the table space available, you can either back up the
entire database, the table space that is in the backup pending state, or a set
of table spaces that includes the table space that is in the backup pending
state.)
Database Time of roll forward of Restore
backup. table space TABSP1 to database.
T2. Back up TABSP1. Roll forward
to end of logs.
T1 T2 T3 T4
| | | |
| | | |
|--------------------------------------------------------------------------------
| Logs are not
applied to TABSP1
between T2 and T3
when it is rolled
forward to T2.
In the preceding example, you back up the database at time T1. Then,
at time T3, you roll forward table space TABSP1 to the point in time T2, then
take a back up of the table space after T3. (Because the table space is
in the backup pending state, you must take a backup of it. The
timestamp of the table space backup is after T3, but the table space is at
time T2. Log records are not applied to TABSP1 from between T2 and
T3.) At time T4, you restore the database with the backup you took at
T1 and roll forward to the end of the logs. The table space TABSP1 will
be placed into the restore pending state when time T3 is reached.
The table space is put into the restore pending state at T3 because the
database manager assumes that operations were performed on TABSP1 between T3
and T4 without the log changes between T2 and T3 having been applied to the
table space. If the log changes between T2 and T3 were reapplied as
part of the ROLLFORWARD on the database, this assumption would be
violated. The required backup of a table space that must be taken after
it is rolled forward to a point in time allows you to roll that table space
forward past a previous point-in-time roll forward (T3 in the
example).
Assuming that you want to recover table space TABSP1 to T4, you would
restore the table space from a backup that was taken after T3 (either the
required backup, or a later one) then roll forward TABSP1 to the end of the
logs.
In the preceding example, the most efficient way of restoring the database
to time T4 would be to perform the required steps in the following
order. Because you restore the table space before rolling forward the
database, resource is not used to apply log records to the table space when
the database is rolled forward, which would happen if you rolled forward the
database before you restored the table space.
- Restore the database.
- Restore the table space.
- Roll forward the database.
- Roll forward the table space.
If you cannot find back up image of TABSP1 that is after time T3, or you
want to restore TABSP1 to T3 or before, you can:
- Roll forward the table space to the T3 point in time. You do not
need to restore the table space again because it was restored from the
database backup.
- Restore the table space again from the backup of the database that you
took at time T1, then roll forward the table space to a time that precedes
time T3.
- Drop the table space.
In a partitioned database environment you must roll forward all portions of
the table space to the same point in time at the same time. This
ensures that the table space is consistent across database
partitions.
Before using the ROLLFORWARD command you should consider the following
items:
- You must have SYSADM, SYSCTRL, or SYSMAINT authority.
- The database may be local or remote.
- In a partitioned database environment, the rollforward must be issued from
the catalog node of the database.
- The database must be configured for roll-forward recovery (that is, either
logretain, userexit, or both must be enabled).
When a database is first configured for the roll-forward function, you must
make a backup copy of it.
- A database must be restored successfully (using the RESTORE command)
before it can be rolled forward; but a table space does not. A
table space may be temporarily put into the roll-forward pending state, but
not require a restore to fix it (for example, if a power interruption
occurs).
- A database roll forward runs offline. The database is not available
for use until the roll forward completes (either by reaching the end of the
logs during a table space rollforward, or by specifying STOP on the
ROLLFORWARD command). You can, however, perform an online roll forward
of table spaces as long as SYSCATSPACE is not included. When you
perform an online roll-forward operation on a table space, it is not available
for use, but the other table spaces in the database are.
- When rolling forward, you should:
- Issue ROLLFORWARD (without the STOP option).
- Issue ROLLFORWARD QUERY STATUS.
If you perform end-of-log forward recovery, the QUERY STATUS can indicate
that a log file (or files) is missing if the point in time returned by QUERY
STATUS is earlier than you expect.
If you perform point-in-time forward recovery, the QUERY STATUS will help
you ensure that the roll forward is to the correct point.
- Issue ROLLFORWARD STOP. After a ROLLFORWARD STOP, it is not
possible to roll forward additional changes.
- You can perform a partial or subset restore of a backup created using the
current version of DB2. This cannot be done with earlier versions of
DB2.
- A table space requires roll-forward recovery if it is in a roll-forward
pending state. It is in this state following a table space level
restore or being taken offline because of a media error.
Figure 32. Table Space Roll-forward Recovery
- You do not have to recover your database with the latest backup copy of
the database: you can start with any backup, as long as you have the
logs associated with and following that backup.
- You should continue to make periodic backups of a database in order to
reduce recovery time.
- If you need to cancel a roll-forward operation (that is, ROLLFORWARD STOP
was not specified, or the ROLLFORWARD command failed) to start it over again,
you can use ROLLFORWARD CANCEL to cancel the operation.
If you use ROLLFORWARD CANCEL against a database, this places the database
into the restore pending state, whether or not a roll forward is in progress
against the database.
ROLLFORWARD CANCEL behavior for table spaces is as follows:
- If you issue ROLLFORWARD CANCEL and you specify a list of table spaces
that are in the roll-forward pending state, they are put in the restore
pending state.
Note: | If no table space list is specified, SQL4906 is issued.
|
- If multiple table spaces are being rolled forward to the end of the logs
and you specify ROLLFORWARD CANCEL with a list, only the table spaces that are
in the list are put in the restore pending state. The table spaces that
are not in the list remain in the rollforward-in-progress state. If you
specify ROLLFORWARD CANCEL without a list, all table spaces that are in the
rollforward-in-progress state are put in the restore pending state.
- If you issue ROLLFORWARD CANCEL and one or more table spaces are being
rolled forward to a point in time, they are all put in the restore pending
state, whether you specify a list or not. Even if you specify a list,
the list is ignored and all table spaces that are in the
roll-forward-in-progress state are put in the restore pending state.
Note: | You cannot use ROLLFORWARD CANCEL to cancel a roll-forward operation that is
running. You can only use it to cancel a roll-forward operation that
completed but did not have ROLLFORWARD STOP issued for it, or for a
roll-forward operation that failed before completing.
|
If you have tables that contain DATALINK columns, also see "Restore and Rollforward Utility Considerations".
There are a number of considerations before invoking the ROLLFORWARD
command:
- When you invoke the ROLLFORWARD command, you can specify a time to limit
the transactions that will be recovered from the database logs. If you
are restoring from a backup that was created using the online
option of the BACKUP command, the time on the ROLLFORWARD command must be
later than the online backup end time.
- A log uses a timestamp associated with the completion of a unit of
work. The timestamp in the logs uses the Coordinated Universal Time
(CUT), which helps to avoid having the same timestamp associated with
different logs (because of a change in time associated with daylight savings
time, for example). The timestamp used on the backup is based on the
local time that the BACKUP started. As a result, when you call the
ROLLFORWARD command, you must specify the time in Coordinated Universal
Time.
Notes:
- The special register, CURRENT TIMEZONE, holds the difference between CUT
and the local time at the application server database. Local time is
the CUT plus the current timezone contents.
- If you are rolling forward a table space (or table spaces) to a point in
time, you must roll forward at least to the minimum recovery time, which is
the last update to the system catalogs for this table space, or its
tables.
- If you stop the ROLLFORWARD task before it passes the point that the
online backup ended, the database is left in a roll-forward pending
state. If a table space is being rolled forward, it is left in the
rollforward-in-progress state.
The DB2LOADREC environment variable is used to identify the file with the
load copy location information. This file is used during roll-forward
recovery to locate the load copy. It has information on:
- Media type
- Number of media devices to be used
- Location of the load copy generated during table load
- Filename of the load copy, if applicable
If the location file does not exist or no matching entry is found in the
file, the information from the log record is used.
The information in the file may be overwritten before the roll-forward
recovery takes place.
Notes:
- In a partitioned database environment, the DB2LOADREC environment variable
must be in the db2profile file.
- In a partitioned database environment, the load copy file must exist at
each database partition server, and the file name (including the path) must be
the same.
The following information is provided in the location file. The
first five parameters must have valid values and are used to identify the load
copy. The entire structure is repeated for each load copy
recorded. For example:
TIMestamp 19950725182542 * Timestamp generated at load time
SCHema PAYROLL * Schema of table loaded
TABlename EMPLOYEES * Table name
DATabasename DBT * Database name
DB2instance TORONTO * DB2INSTANCE
BUFfernumber NULL * Number of buffers to be used for recovery
SESsionnumber NULL * Number of sessions to be used for recovery
TYPeofmedia L * Type of media - L for local device
A for ADSM
O for other vendors
LOCationnumber 3 * Number of locations
ENTry /u/toronto/dbt.payroll.employes.001
ENT /u/toronto/dbt.payroll.employes.002
ENT /dev/rmt0
TIM 19950725192054
SCH PAYROLL
TAB DEPT
DAT DBT
DB2 TORONTO
SES NULL
BUF NULL
TYP A
TIM 19940325192054
SCH PAYROLL
TAB DEPT
DAT DBT
DB2 TORONTO
SES NULL
BUF NULL
TYP O
SHRlib /@sys/lib/backup_vendor.a
Notes:
- The first 3 characters for each keyword are significant. All
keywords are required in the specified order. No blank lines will be
accepted.
- The timestamp is in the format yyyymmddhhmmss.
- All fields are mandatory except for BUF and SES which may be NULL.
If SES is NULL, the value specified by configuration parameter NUMLOADRECSES
will be used. If BUF is NULL, the default is SES+2.
- The type of media may be local device (L for tape, disk or diskettes),
ADSM (A) or other vendor (O). If it is 'L', the number of
locations followed by the location entries are required. If the type is
'A', no further input is required. If the type is
'O', the shared library name is required. For details about
using ADSM and other vendor products as backup media, see "ADSTAR Distributed Storage Manager".
- The SHRlib parameter points to a library that has function to store the
LOAD COPY data.
Note: | If you run LOAD COPY NO and do not take a backup copy of the database or
affected table spaces after running LOAD, you cannot restore the database or
table spaces to a point in time after the LOAD was performed. That is,
you cannot use roll-forward recovery to rebuild the database or table spaces
to a state after the LOAD. You can only restore the database or table
spaces to a point in time that precedes the LOAD.
|
If you want to use a particular load copy, the LOAD timestamps are recorded
in the recovery history file for the database. In a partitioned
database environment, the recovery history file is local to each database
partition.
For more information on LOAD, see "Using the LOAD Utility".
There are items to be considered when managing database
logs:
- The numbering scheme for archived logs starts with S0000000.LOG,
and goes through S9999999.LOG (10 000 000
logs). The database manager restarts using S0000000.LOG under
these conditions:
- When a database configuration file is changed to enable the roll-forward
function.
- When a database configuration file is changed to disable the roll-forward
function.
- When the logs wrap; that is, after log S9999999.LOG is used.
When the roll-forward recovery method completes successfully, the last log
is truncated, and logging begins with the next sequential log. The
practical effect is that any log in the log path directory with a sequence
number greater than the last log used for roll-forward recovery is
re-used. You should keep a copy of the logs elsewhere if you want to be
able to re-execute the ROLLFORWARD command using these old logs. (You
may use a user exit program to copy the logs to another location.)
You can have duplicate names for different logs because:
- The database manager starts renaming logs with S0000000.LOG (as
described above),
- The database manager reuses log names after restoring a database (with or
without roll-forward recovery).
The database manager ensures that an incorrect log is not applied during
roll-forward recovery, but it cannot detect the location of the required
log. You must ensure that the correct logs are available for
roll-forward recovery.
- If you moved log files to a location other than that specified by the
logpath database configuration parameter, use the OVERFLOW LOG PATH
parameter of the ROLLFORWARD command to specify the additional path to
them.
If you are rolling forward changes in a database or table space and the
roll-forward operation cannot find the next log, the log name is returned in
the SQLCA, indicating the next log file needed, and roll-forward recovery
stops. At this time, if there are no more logs available, you can use
the ROLLFORWARD command to stop processing.
If you terminate the roll-forward recovery (by specifying the STOP option
on the ROLLFORWARD command) and the log containing the completion of a
transaction has not been applied to the database or table space, the
incomplete transaction will be rolled back to ensure that the database or
table space is left in a consistent state.
-
Archived logs are placed in the SQLOGDIR subdirectory by default. To
place them elsewhere, either enable the database for user exit, or use the
OVERFLOW LOG PATH parameter of the ROLLFORWARD command to point to them when
you roll forward.
- If you enable a user exit by changing the database configuration file, the
archived logs can be redirected to a user-defined storage device such as a
tape drive. Also, you can use a user exit program to manage the storage
of archived logs. See Appendix L. "User Exit for Database Recovery" for information about a user exit program.
- If you change the newlogpath parameter, any existing archived
logs are unaffected. You must keep track of the location of the
logs.
- If a database enabled for roll-forward recovery is restored either without
being rolled forward or with being rolled forward to a specific time, an
archived log may be associated with two or more different log sequences of a
database, because log names are reused. (Figure 33 provides an illustration of the logs that are created. If you now do
a restore using "Backup 2" you must take extra care since there are two
log sequences which could be used.) Before discarding an archived log,
you must ensure that you do not need it.
Figure 33. Reusing Log File Names
- If during a full database recovery you have rolled forward to a point in
time and stopped in the middle of the logs, you have created a new log
sequence. The two (2) log sequences cannot be combined. If you
have an online backup that spans through the first log sequence, you must use
the first log sequence to complete the roll forward recovery.
- If you have created a new log sequence after recovery, any table space
backups taken in the old log sequence are invalidated. Restore rejects
the table space backups in this case. There may be instances where
restore fails to recognize that the backup is no longer valid (particularly
for online backups) and the restore is successful. However,
roll-forward for the table space will fail and the table space is left in a
roll-forward pending state.
In the diagram above, assume that a table space backup, Backup 3, is
completed between S0000013.LOG and
S0000014.LOG in the top log sequence. If we restored
and rolled forward using database Backup 2, we would need to roll-forward
through S0000012.LOG. After this we could continue to
roll-forward through either the top log sequence or the newer bottom log
sequence. If we rolled forward through the bottom sequence, we would
not be able to use the table space Backup 3 to do a table space restore and
roll-forward recovery.
To be able to complete a table space roll-forward to end of logs using the
table space Backup 3, we would have to restore using database Backup 2 and
then roll-forward using the top log sequence. Once the table space
Backup 3 has been restored, you can then request a roll-forward to end of
logs.
- A log uses a timestamp associated with the completion of a unit of
work. The timestamp in the logs uses the Coordinated Universal Time
(CUT), which helps to avoid having the same timestamp associated with
different logs (because of a change in time associated with daylight savings
time, for example). The timestamp used on the backup is based on the
local time. As a result, when you call the ROLLFORWARD command, you
must specify the time in Coordinated Universal Time.
Note: | The special register, CURRENT TIMEZONE, holds the difference between CUT and
the local time at the application server database. Local time is the
CUT plus the current timezone contents.
|
- Dropping a database erases all logs in the current database log path
directory. Before dropping a database, you may need to make copies of
the logs.
- If you are rolling forward a database to a point-in-time, the last log
used in the roll-forward recovery and all existing logs following that are
reused. You lose the ability to recover past that particular
point-in-time. Therefore, you should copy all the logs in the current
database log path directory before beginning a point-in-time
recovery.
When the roll-forward processing completes, the log file with the last
committed transaction is truncated, and logging begins with the next
sequential log. If you do not have a copy of the log before it was
truncated and those with higher sequence numbers, you cannot recover the
database past the specified point-in-time. (Once normal database
activity occurs following the roll-forward, new logs are created which can
then be used in any subsequent recovery.)
- If you change the log path directory and then remove the subdirectory or
erase any logs in that subdirectory called for in the log path, the database
manager will look for the logs in the default log path, SQLOGDIR, when the
database is opened. If the logs are not found, the database will enter
a backup pending state, and you must back up the database before it is
usable.
This backup must be made even if the subdirectory contained empty
logs.
- If you lose the log containing the point in time of the end of the online
backup and you are rolling forward the corresponding restored image, the
database will not be usable. To make the database usable, you must
restore the database from a different backup and all associated logs.
You may encounter a situation similar to the following: You would
like to do a point-in-time recovery on a full database but you are concerned
that you might lose a log during the recovery process. (This scenario
could occur if you have an extended number of archived logs between the time
of the last backup database image and the point-in-time where you would like
to have the database recovered.)
First, you should copy all of the applicable logs to a "safe"
location. Then you can run the RESTORE command and use the roll-forward
recovery method to the point-in-time you wish for the database. If any
of the logs that you need is damaged or lost during this process, you have a
backup copy of all of the logs elsewhere.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
[ DB2 List of Books |
Search the DB2 Books ]