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