Library Version 11.2.5.3

Removing Log Files
Prev | Chapter 5. Managing DB Files | Next

## Removing Log Files

By default DB does not delete log files for you. For this reason, DB's log files will eventually grow to consume an unnecessarily large amount of disk space. To guard against this, you should periodically take administrative action to remove log files that are no longer in use by your application.

You can remove a log file if all of the following are true:

- the log file is not involved in an active transaction.

- a checkpoint has been performed after the log file was created.

- the log file is not the only log file in the environment.

- the log file that you want to remove has already been included in an offline or hot backup. Failure to observe this last condition can cause your backups to be unusable.

DB provides several mechanisms to remove log files that meet all but the last criteria (DB has no way to know which log files have already been included in a backup). The following mechanisms make it easy to remove unneeded log files, but can result in an unusable backup if the log files are not first saved to your archive location. All of the following mechanisms automatically delete unneeded log files for you:

- Run the db_archive command line utility with the `-d` option.

- From within your application, call the `DbEnv::log_archive()` method with the `DB_ARCH_REMOVE` flag.

- Call `DbEnv::log_set_config()` method with the `DB_LOG_AUTO_REMOVE` flag. Note that this flag can be set at any point in the lifetime of your application. Setting this parameter affects all environment handles opened against the environment; not just the handle used to set the flag.

  Note that unlike the other log removal mechanisms identified here, this method actually causes log files to be removed on an on-going basis as they become unnecessary. This is extremely desirable behavior if what you want is to use the absolute minimum amount of disk space possible for your application. This mechanism will leave you with the log files that are required to run normal recovery. However, it is highly likely that this mechanism will prevent you from running catastrophic recovery.

  Do NOT use this mechanism if you want to be able to perform catastrophic recovery, or if you want to be able to maintain a hot backup.

In order to safely remove log files and still be able to perform catastrophic recovery, use the db_archive command line utility as follows:

1. Run either a normal or hot backup as described in Backup Procedures. Make sure that all of this data is safely stored to your backup media before continuing.

2. If you have not already done so, perform a checkpoint. See Checkpoints for more information.

3. If you are maintaining a hot backup, perform the hot backup procedure as described in Using Hot Failovers.

4. Run the db_archive command line utility with the `-d` option against your production environment.

5. Run the db_archive command line utility with the `-d` option against your failover environment, if you are maintaining one.

Prev | Up | Next
Using Hot Failovers | Home | Configuring the Logging Subsystem