| 1 |
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 |
<title>Removing Log Files</title> |
| 7 |
<link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 |
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 |
<link rel="start" href="index.html" title="Getting Started with Berkeley DB Transaction Processing" /> |
| 10 |
<link rel="up" href="filemanagement.html" title="Chapter 5. Managing DB Files" /> |
| 11 |
<link rel="prev" href="hotfailover.html" title="Using Hot Failovers" /> |
| 12 |
<link rel="next" href="logconfig.html" title="Configuring the Logging Subsystem" /> |
| 13 |
</head> |
| 14 |
<body> |
| 15 |
<div xmlns="" class="navheader"> |
| 16 |
<div class="libver"> |
| 17 |
<p>Library Version 11.2.5.3</p> |
| 18 |
</div> |
| 19 |
<table width="100%" summary="Navigation header"> |
| 20 |
<tr> |
| 21 |
<th colspan="3" align="center">Removing Log Files</th> |
| 22 |
</tr> |
| 23 |
<tr> |
| 24 |
<td width="20%" align="left"><a accesskey="p" href="hotfailover.html">Prev</a> </td> |
| 25 |
<th width="60%" align="center">Chapter 5. Managing DB Files</th> |
| 26 |
<td width="20%" align="right"> <a accesskey="n" href="logconfig.html">Next</a></td> |
| 27 |
</tr> |
| 28 |
</table> |
| 29 |
<hr /> |
| 30 |
</div> |
| 31 |
<div class="sect1" lang="en" xml:lang="en"> |
| 32 |
<div class="titlepage"> |
| 33 |
<div> |
| 34 |
<div> |
| 35 |
<h2 class="title" style="clear: both"><a id="logfileremoval"></a>Removing Log Files</h2> |
| 36 |
</div> |
| 37 |
</div> |
| 38 |
</div> |
| 39 |
<p> |
| 40 |
By default DB does not delete log files for you. For this reason, |
| 41 |
DB's log files will eventually grow to consume an |
| 42 |
unnecessarily large amount of disk space. To guard against |
| 43 |
this, you should periodically take administrative action to |
| 44 |
remove log files that are no longer in use by your application. |
| 45 |
</p> |
| 46 |
<p> |
| 47 |
You can remove a log file if all of the following are true: |
| 48 |
</p> |
| 49 |
<div class="itemizedlist"> |
| 50 |
<ul type="disc"> |
| 51 |
<li> |
| 52 |
<p> |
| 53 |
the log file is not involved in an active transaction. |
| 54 |
</p> |
| 55 |
</li> |
| 56 |
<li> |
| 57 |
<p> |
| 58 |
a checkpoint has been performed |
| 59 |
<span class="emphasis"><em>after</em></span> the log file was |
| 60 |
created. |
| 61 |
</p> |
| 62 |
</li> |
| 63 |
<li> |
| 64 |
<p> |
| 65 |
the log file is not the only log file in the |
| 66 |
environment. |
| 67 |
</p> |
| 68 |
</li> |
| 69 |
<li> |
| 70 |
<p> |
| 71 |
the log file that you want to remove has already been |
| 72 |
included in an offline or hot backup. |
| 73 |
Failure to observe this last condition can cause your |
| 74 |
backups to be unusable. |
| 75 |
</p> |
| 76 |
</li> |
| 77 |
</ul> |
| 78 |
</div> |
| 79 |
<p> |
| 80 |
DB provides several mechanisms to remove log files that |
| 81 |
meet all but the last criteria (DB has no way to know which |
| 82 |
log files have already been included in a backup). The |
| 83 |
following mechanisms make it easy to remove unneeded log files, |
| 84 |
but can result in an unusable backup if the log files are not first |
| 85 |
saved to your archive location. All of the following |
| 86 |
mechanisms automatically delete unneeded log files for you: |
| 87 |
</p> |
| 88 |
<div class="itemizedlist"> |
| 89 |
<ul type="disc"> |
| 90 |
<li> |
| 91 |
<p> |
| 92 |
Run the <span class="command"><strong>db_archive</strong></span> command line |
| 93 |
utility with the <code class="literal">-d</code> option. |
| 94 |
</p> |
| 95 |
</li> |
| 96 |
<li> |
| 97 |
<p> |
| 98 |
From within your application, call the |
| 99 |
<span> |
| 100 |
<code class="methodname">DB_ENV->log_archive()</code> |
| 101 |
|
| 102 |
method with the <code class="literal">DB_ARCH_REMOVE</code> flag. |
| 103 |
</span> |
| 104 |
|
| 105 |
</p> |
| 106 |
</li> |
| 107 |
<li> |
| 108 |
<p> |
| 109 |
<span> |
| 110 |
Call |
| 111 |
<span> |
| 112 |
<code class="methodname">DB_ENV->log_set_config()</code> |
| 113 |
|
| 114 |
method with the <code class="literal">DB_LOG_AUTO_REMOVE</code> flag. |
| 115 |
</span> |
| 116 |
|
| 117 |
Note that this flag can be set at any point in |
| 118 |
the lifetime of your application. Setting this |
| 119 |
parameter affects all environment handles |
| 120 |
opened against the environment; not just the |
| 121 |
handle used to set the flag. |
| 122 |
</span> |
| 123 |
|
| 124 |
</p> |
| 125 |
<p> |
| 126 |
Note that unlike the other log removal mechanisms |
| 127 |
identified here, this method actually causes log files |
| 128 |
to be removed on an on-going basis as they become |
| 129 |
unnecessary. This is extremely desirable behavior if |
| 130 |
what you want is to use the absolute minimum amount of |
| 131 |
disk space possible for your application. This |
| 132 |
mechanism <span class="emphasis"><em>will</em></span> leave you with |
| 133 |
the log files that are required to run normal recovery. |
| 134 |
However, it is highly likely that this mechanism will |
| 135 |
prevent you from running catastrophic recovery. |
| 136 |
</p> |
| 137 |
<p> |
| 138 |
Do NOT use this mechanism if you want to be able to |
| 139 |
perform catastrophic recovery, or if you want to be |
| 140 |
able to maintain a hot backup. |
| 141 |
</p> |
| 142 |
</li> |
| 143 |
</ul> |
| 144 |
</div> |
| 145 |
<p> |
| 146 |
In order to safely remove log files and still be able to |
| 147 |
perform catastrophic recovery, use the |
| 148 |
<span class="command"><strong>db_archive</strong></span> command line utility as follows: |
| 149 |
</p> |
| 150 |
<div class="orderedlist"> |
| 151 |
<ol type="1"> |
| 152 |
<li> |
| 153 |
<p> |
| 154 |
Run either a normal or hot backup as described in |
| 155 |
<a class="xref" href="backuprestore.html" title="Backup Procedures">Backup Procedures</a>. Make |
| 156 |
sure that all of this data is safely stored to your |
| 157 |
backup media before continuing. |
| 158 |
</p> |
| 159 |
</li> |
| 160 |
<li> |
| 161 |
<p> |
| 162 |
If you have not already done so, perform a checkpoint. |
| 163 |
See <a class="xref" href="filemanagement.html#checkpoints" title="Checkpoints">Checkpoints</a> |
| 164 |
for more information. |
| 165 |
</p> |
| 166 |
</li> |
| 167 |
<li> |
| 168 |
<p> |
| 169 |
If you are maintaining a hot backup, perform the hot |
| 170 |
backup procedure as described in |
| 171 |
<a class="xref" href="hotfailover.html" title="Using Hot Failovers">Using Hot Failovers</a>. |
| 172 |
</p> |
| 173 |
</li> |
| 174 |
<li> |
| 175 |
<p> |
| 176 |
Run the <span class="command"><strong>db_archive</strong></span> command line |
| 177 |
utility with the <code class="literal">-d</code> option against |
| 178 |
your production environment. |
| 179 |
</p> |
| 180 |
</li> |
| 181 |
<li> |
| 182 |
<p> |
| 183 |
Run the <span class="command"><strong>db_archive</strong></span> command line |
| 184 |
utility with the <code class="literal">-d</code> option against |
| 185 |
your failover environment, if you are maintaining one. |
| 186 |
</p> |
| 187 |
</li> |
| 188 |
</ol> |
| 189 |
</div> |
| 190 |
</div> |
| 191 |
<div class="navfooter"> |
| 192 |
<hr /> |
| 193 |
<table width="100%" summary="Navigation footer"> |
| 194 |
<tr> |
| 195 |
<td width="40%" align="left"><a accesskey="p" href="hotfailover.html">Prev</a> </td> |
| 196 |
<td width="20%" align="center"> |
| 197 |
<a accesskey="u" href="filemanagement.html">Up</a> |
| 198 |
</td> |
| 199 |
<td width="40%" align="right"> <a accesskey="n" href="logconfig.html">Next</a></td> |
| 200 |
</tr> |
| 201 |
<tr> |
| 202 |
<td width="40%" align="left" valign="top">Using Hot Failovers </td> |
| 203 |
<td width="20%" align="center"> |
| 204 |
<a accesskey="h" href="index.html">Home</a> |
| 205 |
</td> |
| 206 |
<td width="40%" align="right" valign="top"> Configuring the Logging Subsystem</td> |
| 207 |
</tr> |
| 208 |
</table> |
| 209 |
</div> |
| 210 |
</body> |
| 211 |
</html> |