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