2
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
4
<!--See the file LICENSE for redistribution information.-->
7
<title>Berkeley DB Reference Guide: Hot failover</title>
8
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
9
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
12
<a name="2"><!--meow--></a>
13
<table width="100%"><tr valign=top>
14
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Transactional Data Store Applications</dl></h3></td>
15
<td align=right><a href="../../ref/transapp/recovery.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/transapp/filesys.html"><img src="../../images/next.gif" alt="Next"></a>
18
<h1 align=center>Hot failover</h1>
19
<p>For some applications, it may be useful to periodically snapshot the
20
database environment for use as a hot failover should the primary system
21
fail. The following steps can be taken to keep a backup environment in
22
close synchrony with an active environment. The active environment is
23
entirely unaffected by these procedures, and both read and write
24
operations are allowed during all steps described here.
26
<p><li>Run <a href="../../utility/db_archive.html">db_archive</a> <b>-s</b> in the active environment to
27
identify all of the active environment's database files, and copy them
28
to the backup directory.
29
<p>If the database files are stored in a separate directory from the other
30
Berkeley DB files, it may be simpler to copy the directory itself instead of
31
the individual files (see <a href="../../api_c/env_set_data_dir.html">DB_ENV->set_data_dir</a> for additional
32
information). <b>Note: if any of the database files did not have
33
an open <a href="../../api_c/db_class.html">DB</a> handle during the lifetime of the current log files,
34
<a href="../../utility/db_archive.html">db_archive</a> will not list them in its output!</b> This is another
35
reason it may be simpler to use a separate database file directory and
36
copy the entire directory instead of archiving only the files listed by
37
<a href="../../utility/db_archive.html">db_archive</a>.
38
<p><li>Remove all existing log files from the backup directory.
39
<p><li>Run <a href="../../utility/db_archive.html">db_archive</a> <b>-l</b> in the active environment to
40
identify all of the active environment's log files, and copy them to
42
<p><li>Run <a href="../../utility/db_recover.html">db_recover</a> <b>-c</b> in the backup directory to
43
catastrophically recover the copied environment.
45
<p>Steps 2, 3 and 4 may be repeated as often as you like. If Step 1 (the
46
initial copy of the database files) is repeated, then Steps 2, 3 and 4
47
<b>must</b> be performed at least once in order to ensure a consistent
48
database environment snapshot.
49
<p>These procedures must be integrated with your other archival procedures,
50
of course. If you are periodically removing log files from your active
51
environment, you must be sure to copy them to the backup directory
52
before removing them from the active directory. Not copying a log file
53
to the backup directory and subsequently running recovery with it
54
present may leave the backup snapshot of the environment corrupted. A
55
simple way to ensure this never happens is to archive the log files in
56
Step 2 as you remove them from the backup directory, and move inactive
57
log files from your active environment into your backup directory
58
(rather than copying them), in Step 3. The following steps describe
59
this procedure in more detail:
61
<p><li>Run <a href="../../utility/db_archive.html">db_archive</a> <b>-s</b> in the active environment to
62
identify all of the active environment's database files, and copy them
63
to the backup directory.
64
<p><li>Archive all existing log files from the backup directory, moving them
65
to a backup device such as CD-ROM, alternate disk, or tape.
66
<p><li>Run <a href="../../utility/db_archive.html">db_archive</a> (without any option) in the active environment
67
to identify all of the log files in the active environment that are no
68
longer in use, and <b>move</b> them to the backup directory.
69
<p><li>Run <a href="../../utility/db_archive.html">db_archive</a> <b>-l</b> in the active environment to
70
identify all of the remaining log files in the active environment, and
71
<b>copy</b> the log files to the backup directory.
72
<p><li>Run <a href="../../utility/db_recover.html">db_recover</a> <b>-c</b> in the backup directory to
73
catastrophically recover the copied environment.
75
<p>As before, steps 2, 3, 4 and 5 may be repeated as often as you like.
76
If Step 1 (the initial copy of the database files) is repeated, then
77
Steps 2 through 5 <b>must</b> be performed at least once in order to
78
ensure a consistent database environment snapshot.
79
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/transapp/recovery.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/transapp/filesys.html"><img src="../../images/next.gif" alt="Next"></a>
81
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>