1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hot failover</title>
<link rel="stylesheet" href="gettingStarted.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
<link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
<link rel="up" href="transapp.html" title="Chapter 11. Berkeley DB Transactional Data Store Applications" />
<link rel="prev" href="transapp_recovery.html" title="Recovery procedures" />
<link rel="next" href="transapp_filesys.html" title="Recovery and filesystem operations" />
</head>
<body>
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">Hot failover</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="transapp_recovery.html">Prev</a> </td>
<th width="60%" align="center">Chapter 11.
Berkeley DB Transactional Data Store Applications
</th>
<td width="20%" align="right"> <a accesskey="n" href="transapp_filesys.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="transapp_hotfail"></a>Hot failover</h2>
</div>
</div>
</div>
<p>For some applications, it may be useful to periodically snapshot the
database environment for use as a hot failover should the primary system
fail. The following steps can be taken to keep a backup environment in
close synchrony with an active environment. The active environment is
entirely unaffected by these procedures, and both read and write
operations are allowed during all steps described here.</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>
Run the <a href="../api_reference/C/db_archive.html" class="olink">db_archive utility</a> with the <span class="bold"><strong>-s</strong></span> option in the active environment
to identify all of the active environment's database files, and
copy them to the backup directory.
</p>
<p>
If the database files are stored in a separate directory from
the other Berkeley DB files, it will be simpler (and much
faster!) to copy the directory itself instead of the individual
files (see <a href="../api_reference/C/envset_data_dir.html" class="olink">DB_ENV->set_data_dir()</a> for additional information).
<span class="bold"><strong>Note: if any of the database files did
not have an open <a href="../api_reference/C/db.html" class="olink">DB</a> handle during the lifetime of the
current log files, the <a href="../api_reference/C/db_archive.html" class="olink">db_archive utility</a> will not list them in
its output!</strong></span> This is another reason it may be
simpler to use a separate database file directory and copy the
entire directory instead of archiving only the files listed by
the <a href="../api_reference/C/db_archive.html" class="olink">db_archive utility</a>.
</p>
</li>
<li>Remove all existing log files from the backup directory.</li>
<li>
Run the <a href="../api_reference/C/db_archive.html" class="olink">db_archive utility</a> with the <span class="bold"><strong>-l</strong></span>
option in the active environment to identify all of the active
environment's log files, and copy them to the backup directory.
</li>
<li>
Run the <a href="../api_reference/C/db_recover.html" class="olink">db_recover utility</a> with the <span class="bold"><strong>-c</strong></span>
option in the backup directory to catastrophically recover the
copied environment.
</li>
</ol>
</div>
<p>Steps 2, 3 and 4 may be repeated as often as you like. If Step 1 (the
initial copy of the database files) is repeated, then Steps 2, 3 and 4
<span class="bold"><strong>must</strong></span> be performed at least once in order to ensure a consistent
database environment snapshot.</p>
<p>These procedures must be integrated with your other archival procedures,
of course. If you are periodically removing log files from your active
environment, you must be sure to copy them to the backup directory
before removing them from the active directory. Not copying a log file
to the backup directory and subsequently running recovery with it
present may leave the backup snapshot of the environment corrupted. A
simple way to ensure this never happens is to archive the log files in
Step 2 as you remove them from the backup directory, and move inactive
log files from your active environment into your backup directory
(rather than copying them), in Step 3. The following steps describe
this procedure in more detail:</p>
<div class="orderedlist">
<ol type="1">
<li>
Run the <a href="../api_reference/C/db_archive.html" class="olink">db_archive utility</a> with the <span class="bold"><strong>-s</strong></span>
option in the active environment to identify all of the active
environment's database files, and copy them to the backup
directory.
</li>
<li>
Archive all existing log files from the backup directory, moving them
to a backup device such as CD-ROM, alternate disk, or tape.
</li>
<li>
Run the <a href="../api_reference/C/db_archive.html" class="olink">db_archive utility</a> (without any option) in the active environment
to identify all of the log files in the active environment that are
no longer in use, and <span class="bold"><strong>move</strong></span> them to
the backup directory.
</li>
<li>
Run the <a href="../api_reference/C/db_archive.html" class="olink">db_archive utility</a> with the <span class="bold"><strong>-l</strong></span>
option in the active environment to identify all of the remaining
log files in the active environment, and <span class="bold"><strong>copy</strong></span> the log files to the backup
directory.
</li>
<li>
Run the <a href="../api_reference/C/db_recover.html" class="olink">db_recover utility</a> with the <span class="bold"><strong>-c</strong></span>
option in the backup directory to catastrophically recover the
copied environment.
</li>
</ol>
</div>
<p>As before, steps 2, 3, 4 and 5 may be repeated as often as you like.
If Step 1 (the initial copy of the database files) is repeated, then
Steps 2 through 5 <span class="bold"><strong>must</strong></span> be performed at least once in order to
ensure a consistent database environment snapshot.</p>
<p>
For an example of a hot backup implementation in the Berkeley DB distribution, see the
source code for the <a href="../api_reference/C/db_hotbackup.html" class="olink">db_hotbackup utility</a>.
</p>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="transapp_recovery.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="transapp.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="transapp_filesys.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Recovery procedures </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> Recovery and filesystem operations</td>
</tr>
</table>
</div>
</body>
</html>
|