Previous Topic Next topic Print topic


Media Failure

Restriction: This topic applies to Windows environments only.

Media failure is a serious hardware mishap such as a disk crash.

Media Failure Recovery

You can restore a backup copy of a location's files and replay the contents of a discrete series of log files against the restored location using the ROLLFORWARD command.

A discrete series of log files consists of all changes made to the data objects within an location since the last time the logging system for that location was reset (usually after the last location backup). You must configure the server to ensure that your system is keeping log files. See the section Server Configuration - Delete Old Logs for more information.

If you have made periodic backups of your location (resetting the logging system after each backup), and you have configured your server to keep old logs, you can usually recover from a media failure.

To recover from a media failure:

  1. Shut down the server.
  2. For every location affected by a media failure, use your operating system copy command to archive the current series of log files to a drive and path that is different from any of the location directories you are recovering. Under ideal circumstances, the location log files should be on a different physical drive, separate from the corrupted location files.
  3. Delete current series of log files from the location logging directory.
  4. Locate the latest backup copy of the appropriate location, associated stogroup directories and other related directories.
  5. Restore the backup to the respective drives and paths, using one of the following sets of instructions:
    • If you used the BACKUP LOCATION command:

      Make sure that the server is shut down, and that all destination directories and subdirectories exist (the restore program will not create directories). Then, change to the drive and directory where the backup batch file resides and enter the following at the operating system command line:

      xdbrest

      Any files in the destination directories will be overwritten. Log files will not be restored.

    • If you used your operating system or other utility:

      You must restore files using the compatible operating system restore command prior to recovery.

      If you need to restore location files on a different drive or in different paths than they previously resided, be sure to edit the appropriate system tables to make the XDB Server aware of the new location names and paths. Edit SYSXDB.SYSLOCALS and SYSIBM.SYSLOCATIONS tables to specify location names and path names. Edit SYSIBM.SYSSTOGROUP and SYSIBM.SYSVOLUMES to specify stogroup information. Also check the server machine's configuration file for other special directories, such as index paths.

  6. Bring the server back up.
  7. Before replaying the log files with the ROLLFORWARD command, be sure you are running in Exclusive Use (EU) isolation level. Use the SET ISOLATION command or the Options Utility to change your isolation level. Running in EU gives you total control over the server. Likewise, no incomplete transactions can still be in progress.
  8. Even if only one or more tables within a location need to be restored, the ROLLFORWARD command reconstructs the entire location in question. The ROLLFORWARD command operates on the location level only, restoring one complete location with each execution.
  9. In preparation for replaying all outstanding series of log files against the restored location, create a temporary log file directory and copy the current series of log files (or the most current series of log files if more than one) into that directory. Although not strictly required, resetting location logging after each backup ensures that your current series of log files have recorded only those transactions occurring since the last backup.
  10. From the SQL Wizard (Windows) or Interactive SQL (UNIX), execute a ROLLFORWARD command naming the restored location and the temporary log file directory containing the log files.

    Issue the following SQL command:

    ROLLFORWARD location-name 
        USING log-path

    where location-name is the name of the location containing the restored backup files and log-path is the drive and path name of the directory containing the anchor file and series of log files to be replayed against the restored location. This directory should contain the anchor.log file plus one or more log files beginning with the file named ?0000000.log (where ? = [a-z]).

    For example, the following ROLLFORWARD command would apply the log files contained in the directory c:\xdbnt\logfiles (Windows) or /xdb/logfiles (UNIX) to the system location

    Windows:
    ROLLFORWARD system 
        USING c:\xdbnt\logfiles
    UNIX:
    ROLLFORWARD system 
        USING /xdb/logfiles

    During a ROLLFORWARD, all transactions contained in the location log files are replayed against the restored location.

  11. More than one series of log files may need to be replayed in cases where the location was not backed up (or the backup was corrupted or lost) each time location logging was reset. In these cases, multiple series of log files must be played against the last available backup beginning with the oldest series of log files and finishing with the most recent series.

    In cases where multiple series of log files are being replayed against an older location backup:

    1. Follow the directions in Step 9 to replay the oldest series of log files first (by indicating the directory containing this first series of log files in the ROLLFORWARD command).
    2. Repeat Step A with the next oldest series of log files, being sure to indicate a new directory containing these log files (the same directory can be used as long as the previously replayed series of log files are erased and replaced by the next series).
    3. When the most recent series of log files is ready to be replayed, follow Step 9 one last time to complete the location recovery.

    The sum total of all ROLLFORWARD operations applied against a restored location causes the logging system to run through all the transaction data contained in each series of log files, returning the location to the state it was in immediately before the system failure.

    When the recovery process is complete, press Esc to exit the SQL Wizard (Windows) or Interactive SQL (UNIX).

  12. Shut down the server.
  13. Reset the logging system. See the section Resetting Location Logging.
  14. Start the server. The server is now ready for normal operations to resume.

After all recent log files have been applied to the restored backup copy of the location, your data tables should be returned to a state existing prior to the media failure.

Previous Topic Next topic Print topic