Debian Codegraph @

docs/programmer_reference/transapp_recovery.html

raw symbols SCIP
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>Recovery procedures</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="Berkeley DB Programmer's Reference Guide" />
10 <link rel="up" href="transapp.html" title="Chapter 11.  Berkeley DB Transactional Data Store Applications" />
11 <link rel="prev" href="transapp_logfile.html" title="Log file removal" />
12 <link rel="next" href="transapp_hotfail.html" title="Hot failover" />
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">Recovery procedures</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="transapp_logfile.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 11. 
26 Berkeley DB Transactional Data Store Applications
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="transapp_hotfail.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="transapp_recovery"></a>Recovery procedures</h2>
38 </div>
39 </div>
40 </div>
41 <p>The fifth component of the infrastructure, recovery procedures, concerns
42 the recoverability of the database. After any application or system
43 failure, there are two possible approaches to database recovery:</p>
44 <div class="orderedlist">
45 <ol type="1">
46 <li>There is no need for recoverability, and all databases can be re-created
47 from scratch. Although these applications may still need transaction
48 protection for other reasons, recovery usually consists of removing the
49 Berkeley DB environment home directory and all files it contains, and then
50 restarting the application.
51 Such an application may use the <a href="../api_reference/C/dbset_flags.html#dbset_flags_DB_TXN_NOT_DURABLE" class="olink">DB_TXN_NOT_DURABLE</a> flag to avoid
52 writing log records.</li>
53 <li>
54 <p>
55 It is necessary to recover information after system or application
56 failure. In this case, recovery processing must be performed on
57 any database environments that were active at the time of the
58 failure. Recovery processing involves running the <a href="../api_reference/C/db_recover.html" class="olink">db_recover</a> utility or
59 calling the <a href="../api_reference/C/envopen.html" class="olink">DB_ENV-&gt;open()</a> method with the <a href="../api_reference/C/envopen.html#envopen_DB_RECOVER" class="olink">DB_RECOVER</a> or
60 <a href="../api_reference/C/envopen.html#envopen_DB_RECOVER_FATAL" class="olink">DB_RECOVER_FATAL</a> flags.
61 </p>
62 <p>
63 During recovery processing, all database changes made by aborted or
64 unfinished transactions are undone, and all database changes made
65 by committed transactions are redone, as necessary. Database
66 applications must not be restarted until recovery completes. After
67 recovery finishes, the environment is properly initialized so that
68 applications may be restarted.
69 </p>
70 </li>
71 </ol>
72 </div>
73 <p>If performing recovery, there are two types of recovery processing:
74 <span class="emphasis"><em>normal</em></span> and <span class="emphasis"><em>catastrophic</em></span>.
75 Which you choose depends on the source for the database and log files you are
76 using to recover.</p>
77 <p>
78 If up-to-the-minute database and log files are accessible on a stable
79 filesystem, normal recovery is sufficient. Run the <a href="../api_reference/C/db_recover.html" class="olink">db_recover</a> utility or
80 call the <a href="../api_reference/C/envopen.html" class="olink">DB_ENV-&gt;open()</a> method specifying the <a href="../api_reference/C/envopen.html#envopen_DB_RECOVER" class="olink">DB_RECOVER</a> flag. However, the
81 normal recovery case <span class="bold"><strong>never</strong></span> includes
82 recovery using hot backups of the database environment. For example,
83 you cannot perform a hot backup of databases and log files, restore the
84 backup and then run normal recovery — you must always run catastrophic
85 recovery when using hot backups.
86 </p>
87 <p>
88 If the database or log files have been destroyed or corrupted, or
89 normal recovery fails, catastrophic recovery is required. For example,
90 catastrophic failure includes the case where the disk drive on which
91 the database or log files are stored has been physically destroyed, or
92 when the underlying filesystem is corrupted and the operating system's
93 normal filesystem checking procedures cannot bring that filesystem to a
94 consistent state. This is often difficult to detect, and a common sign
95 of the need for catastrophic recovery is when normal Berkeley DB
96 recovery procedures fail, or when checksum errors are displayed during
97 normal database procedures. When catastrophic recovery is necessary,
98 take the following steps:
99 </p>
100 <div class="orderedlist">
101 <ol type="1">
102 <li>Restore the most recent snapshots of the database and log files from
103 the backup media into the directory where recovery will be performed.</li>
104 <li>
105 <p>
106 If any log files were archived since the last snapshot was made,
107 they should be restored into the directory where recovery will be
108 performed.
109 </p>
110 <p>
111 If any log files are available from the database environment that
112 failed (for example, the disk holding the database files crashed,
113 but the disk holding the log files is fine), those log files should
114 be copied into the directory where recovery will be performed.
115 </p>
116 <p>
117 Be sure to restore all log files in the order they were written.
118 The order is important because it's possible the same log file
119 appears on multiple backups, and you want to run recovery using the
120 most recent version of each log file.
121 </p>
122 </li>
123 <li>
124 <p>
125 Run the <a href="../api_reference/C/db_recover.html" class="olink">db_recover</a> utility, specifying its <span class="bold"><strong>-c</strong></span> option; or call the <a href="../api_reference/C/envopen.html" class="olink">DB_ENV-&gt;open()</a> method,
126 specifying the <a href="../api_reference/C/envopen.html#envopen_DB_RECOVER_FATAL" class="olink">DB_RECOVER_FATAL</a> flag. The catastrophic recovery
127 process will review the logs and database files to bring the
128 environment databases to a consistent state as of the time of the
129 last uncorrupted log file that is found. It is important to
130 realize that only transactions committed before that date will
131 appear in the databases.
132 </p>
133 <p>
134 It is possible to re-create the database in a location different
135 from the original by specifying appropriate pathnames to the
136 <span class="bold"><strong>-h</strong></span> option of the <a href="../api_reference/C/db_recover.html" class="olink">db_recover</a> utility. In
137 order for this to work properly, it is important that your
138 application refer to files by names relative to the database home
139 directory or the pathname(s) specified in calls to
140 <a href="../api_reference/C/envset_data_dir.html" class="olink">DB_ENV-&gt;set_data_dir()</a>, instead of using full pathnames.
141 </p>
142 </li>
143 </ol>
144 </div>
145 </div>
146 <div class="navfooter">
147 <hr />
148 <table width="100%" summary="Navigation footer">
149 <tr>
150 <td width="40%" align="left"><a accesskey="p" href="transapp_logfile.html">Prev</a> </td>
151 <td width="20%" align="center">
152 <a accesskey="u" href="transapp.html">Up</a>
153 </td>
154 <td width="40%" align="right"> <a accesskey="n" href="transapp_hotfail.html">Next</a></td>
155 </tr>
156 <tr>
157 <td width="40%" align="left" valign="top">Log file removal </td>
158 <td width="20%" align="center">
159 <a accesskey="h" href="index.html">Home</a>
160 </td>
161 <td width="40%" align="right" valign="top"> Hot failover</td>
162 </tr>
163 </table>
164 </div>
165 </body>
166 </html>