![]() |
![]() |
|
|
![]() |
![]() |
ALLBASE/SQL Database Administration Guide: HP 9000 Computer Systems > Chapter 6 Backup and Recovery![]() Managing Log Files |
|
The DBA must manage the size, number, and location of ALLBASE/SQL log files. This is done by performing the following tasks using a special set of SQLUtil log management commands:
Use the SHOWLOG command to display the names of the individual log files (single or dual) associated with a DBEnvironment, the archive mode of the log, and the available file space remaining. You can use the SHOWLOG command to display the log file directory either dynamically or statically. The dynamic SHOWLOG is done if you respond Y to the prompt
The default option is a dynamic SHOWLOG. Normally, you should do a dynamic SHOWLOG so as to display the most current information about available log space and about the backup status of log files. You use the static SHOWLOG only when it is not possible to connect to the DBEnvironment, as after a media failure. Here is an example of a dynamic SHOWLOG:
In this example, SHOWLOG displays the following information:
The following is an example of a dynamic SHOWLOG display for a DBEnvironment running in nonarchive mode with dual logging:
In this example, the Log Sequence Number Containing Most Recent Archive Checkpoint and the First Log Sequence Number Needed for Recovery are both 0, since archive logging is off. For a dynamic SHOWLOG, the types of backup status are as follows:
For a static SHOWLOG, the types of backup status are as follows:
You can also use the dynamic SHOWLOG command to display the number of free log blocks (pages) available for logging. In archive mode, SHOWLOG does not tell how many pages are available in previously used log files that have not already been backed up. Until the files are backed up, these log pages are not free. For nonarchive log files, a CHECKPOINT command tells you how many free log file pages there are, and it frees log file pages held by completed transactions. If long transactions tend to fill up the log file, you should increase the log file size. For archive log files, a CHECKPOINT command also tells you how many free log file pages there are, and it frees log file pages in files that have been stored. CHECKPOINT does not tell how many pages are available in previously used log files that have not already been backed up. Moreover, CHECKPOINT uses more system resources than SHOWLOG, which is the preferred method for obtaining the number of free pages. To free log file pages in archive mode, you must back up some of the log files using STORELOG. After backup, these files become available for reuse as soon as there are no active transactions in them. As the number of free log pages approaches zero, you should add log files, or use STORELOG to make a backup of any non-current log file, which then becomes available for reuse. Using multiple log files gives you the greatest flexibility with logging. In nonarchive mode, you can add a file when it is needed for unusually large transactions, and you can recover easily from a LOG FULL condition without having to shut the DBEnvironment down. In archive mode, you can achieve continuous DBEnvironment availability by adding a group of log files, then developing a schedule of DBEnvironment and log backup. To expand the capacity of a nonarchive or archive log, use the ADDLOG command, as in the following example:
If you are using dual logging, enter two log file names separated by a blank. No more than two names are accepted. The minimum size you can specify for an added log file is 250 pages. After you add the file to the DBEnvironment, it will be used when the current log file runs out of space. If you are using archive logging, you must use the STORELOG command to create backups of each log file as it fills up. When a file's status (shown in the dynamic SHOWLOG display) is Ready for Backup, you should use the STORELOG command to store a copy of the log. One method of indicating which file to store is by entering its Log Identifier. Here is an example:
The second method of initiating a log file backup is to issue a STORELOG command and press Return when you see the prompt for a log identifier. In this case, STORELOG will back up the file with the lowest possible sequence number that has Ready for Backup status in the dynamic SHOWLOG display. If the STORELOG operation succeeds, the file will be given the new backup status Backup is Done. A third method of initiating a log file backup is to issue a STORELOG command and enter 0 for the log identifier. In this case, STORELOG will back up all the files which are ready for backup, in the proper sequence by log sequence number, prompting you for filenames as each file is stored. Using this method, all log files can be stored on one tape.
At certain times, it is necessary to store a copy of a log file that is not yet ready for backup with the STORELOG command. One such time is immediately following a media failure. In this event, STORELOG does not work, since it is impossible to CONNECT to the DBEnvironment. Use the RESCUELOG command to store a copy of any log files not yet backed up at the time of the media failure, as in the following:
If the DBECon file is intact, you can use the static SHOWLOG command after a media failure to display the sequence numbers of files with a status of Backup Required. Then you can store these files with RESCUELOG. After a media failure, you prepare for rollforward recovery by restoring the DBEnvironment and the log files. After using RESTORE to restore the DBECon file and all DBEFiles, use the RESTORELOG command to restore each individual log file. The Rename prompt lets you enter a new file name for the log. The input for this prompt is optional, and the default is the original file name. Press Return to use the original file name. The easiest way to restore and apply log files is to use the RESTORELOG and the RECOVERLOG commands one after another for each file, as in the following example:
When a log file has been applied to the DBEnvironment as a part of rollforward recovery, it will be purged by ALLBASE/SQL when it no longer contains active transactions. For that reason, if doing partial recovery in which your current log files are undamaged, make sure that the names given restored log files while using the RESTORELOG command do not conflict with the names of existing log files. Otherwise your existing log files could be purged as RECOVERLOG completes its work. (In fact, partial rollforward recovery is best conducted in a directory which is separated from the one containing your DBEConFile, SYSTEM DBEFileSet, and log files to avoid undesired interaction between files with duplicate names.) Do not attempt to purge logs yourself during the rollforward recovery process. The only way to purge an individual log file that is no longer needed is with the PURGELOG command. Example:
In the case of dual logging, this command purges both filenames associated with the log identifier. You can purge a log file that has been backed up, provided it contains no active transactions. You can also purge a log file that has never been used. You cannot use PURGELOG during the rollforward recovery process. If you wish to purge the DBEnvironment and the entire log, use the PURGEALL command. To purge the DBE alone, use the PURGEDBE command.
You can move a log file from one location to another with the SQLUtil MOVELOG command. Example:
MOVELOG lets you place log files on a device that is separate from the data and index files of the DBEnvironment. Note that when you move a log file, you specify its file name; this means that you can place the different members of a dual log sequence on separate devices if you choose. |
![]() |
||
![]() |
![]() |
![]() |
|||||||||
|