intro.html   [plain text]


<!--$Id: intro.so,v 1.12 2007/12/15 01:15:54 alanb Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Replication introduction</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<a name="2"><!--meow--></a>
<table width="100%"><tr valign=top>
<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Replication</dl></b></td>
<td align=right><a href="../transapp/faq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../rep/id.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p align=center><b>Replication introduction</b></p>
<p>Berkeley DB includes support for building highly available applications based
on replication.  Berkeley DB replication groups consist of some number of
independently configured database environments.  There is a single
<i>master</i> database environment and one or more <i>client</i>
database environments.  Master environments support both database reads
and writes; client environments support only database reads.  If the
master environment fails, applications may upgrade a client to be the
new master.  The database environments might be on separate computers,
on separate hardware partitions in a non-uniform memory access (NUMA)
system, or on separate disks in a single server.
As always with Berkeley DB environments, any number of
concurrent processes or threads may access a database environment.  In
the case of a master environment, any number of threads of control may
read and write the environment, and in the case of a client environment,
any number of threads of control may read the environment.</p>
<p>Applications may be written to provide various degrees of consistency
between the master and clients.  The system can be run synchronously
such that replicas are guaranteed to be up-to-date with all committed
transactions, but doing so may incur a significant performance penalty.
Higher performance solutions sacrifice total consistency, allowing the
clients to be out of date for an application-controlled amount of
time.</p>
<p>There are two ways to build replicated applications.  The simpler way
is to use the Berkeley DB Replication Manager.  The Replication Manager
provides a standard communications infrastructure, and it creates and
manages the background threads needed for processing replication
messages.  (Note that in Replication Manager applications, all updates
to databases at the master environment must be done through a single
DB_ENV environment handle, though they may occur in multiple threads.
This of course means that only a single process may update data.)</p>
<p>The Replication Manager implementation is based on TCP/IP sockets, and
uses POSIX 1003.1 style networking and thread support.  (On Windows
systems, it uses standard Windows thread support.)  As a result, it is
not as portable as the rest of the Berkeley DB library itself.</p>
<p>The alternative is to use the lower-level "Base" replication API.  This
approach affords more flexibility, but requires the application to
provide some critical components:</p>
<ol>
<p><li>A communication infrastructure.  Applications may use whatever wire
protocol is appropriate for their application (for example, RPC, TCP/IP,
UDP, VI or message-passing over the backplane).
<p><li>The application is responsible for naming.  Berkeley DB refers to the members
of a replication group using an application-provided ID, and
applications must map that ID to a particular database environment or
communication channel.
<p><li>The application is responsible for monitoring the status of the master
and clients, and identifying any unavailable database environments.
<p><li>The application must provide whatever security policies are needed.
For example, the application may choose to encrypt data, use a secure
socket layer, or do nothing at all.  The level of security is left to
the sole discretion of the application.
</ol>
<p>(Note that Replication Manager does not provide wire security for
replication messages.)</p>
<p>The following pages present various programming considerations, many of
which are directly relevant only for applications which use the Base
replication API.  However, even when using Replication Manager it is
important to understand the concepts.</p>
<p>Finally, the Berkeley DB replication implementation has one other additional
feature to increase application reliability.  Replication in Berkeley DB is
implemented to perform database updates using a different code path than
the standard ones.  This means operations that manage to crash the
replication master due to a software bug will not necessarily also crash
replication clients.</p>
<!--$Id: m4.methods,v 1.12 2007/10/26 15:43:11 bostic Exp $-->
<table border=1 align=center>
<tr><th>Replication Manager Methods</th><th>Description</th></tr>
<!--DbEnv::repmgr_add_remote_site--><tr><td><a href="../../api_c/repmgr_remote_site.html">DB_ENV-&gt;repmgr_add_remote_site</a></td><td>Specify the replication manager's remote sites</td></tr>
<!--DbEnv::repmgr_set_ack_policy--><tr><td><a href="../../api_c/repmgr_ack_policy.html">DB_ENV-&gt;repmgr_set_ack_policy</a></td><td>Specify the replication manager's client acknowledgement policy</td></tr>
<!--DbEnv::repmgr_set_local_site--><tr><td><a href="../../api_c/repmgr_local_site.html">DB_ENV-&gt;repmgr_set_local_site</a></td><td>Specify the replication manager's local site</td></tr>
<!--DbEnv::repmgr_site_list--><tr><td><a href="../../api_c/repmgr_site_list.html">DB_ENV-&gt;repmgr_site_list</a></td><td>List the sites and their status</td></tr>
<!--DbEnv::repmgr_start--><tr><td><a href="../../api_c/repmgr_start.html">DB_ENV-&gt;repmgr_start</a></td><td>Start the replication manager</td></tr>
<!--DbEnv::repmgr_stat--><tr><td><a href="../../api_c/repmgr_stat.html">DB_ENV-&gt;repmgr_stat</a></td><td>Replication manager statistics</td></tr>
<tr><th>Base Replication API</th><th><br></th></tr>
<!--DbEnv::rep_elect--><tr><td><a href="../../api_c/rep_elect.html">DB_ENV-&gt;rep_elect</a></td><td>Hold a replication election</td></tr>
<!--DbEnv::rep_process_message--><tr><td><a href="../../api_c/rep_message.html">DB_ENV-&gt;rep_process_message</a></td><td>Process a replication message</td></tr>
<!--DbEnv::rep_start--><tr><td><a href="../../api_c/rep_start.html">DB_ENV-&gt;rep_start</a></td><td>Configure an environment for replication</td></tr>
<tr><th>Additional Replication Methods</th><th><br></th></tr>
<!--DbEnv::rep_stat--><tr><td><a href="../../api_c/rep_stat.html">DB_ENV-&gt;rep_stat</a></td><td>Replication statistics</td></tr>
<!--DbEnv::rep_sync--><tr><td><a href="../../api_c/rep_sync.html">DB_ENV-&gt;rep_sync</a></td><td>Replication synchronization</td></tr>
<tr><th>Replication Configuration</th><th><br></th></tr>
<!--DbEnv::rep_set_config--><tr><td><a href="../../api_c/rep_config.html">DB_ENV-&gt;rep_set_config</a></td><td>Configure the replication subsystem</td></tr>
<!--DbEnv::rep_set_clockskew--><tr><td><a href="../../api_c/rep_clockskew.html">DB_ENV-&gt;rep_set_clockskew</a></td><td>Configure master lease clock adjustment</td></tr>
<!--DbEnv::rep_set_limit--><tr><td><a href="../../api_c/rep_limit.html">DB_ENV-&gt;rep_set_limit</a></td><td>Limit data sent in response to a single message</td></tr>
<!--DbEnv::rep_set_nsites--><tr><td><a href="../../api_c/rep_nsites.html">DB_ENV-&gt;rep_set_nsites</a></td><td>Configure replication group site count</td></tr>
<!--DbEnv::rep_set_priority--><tr><td><a href="../../api_c/rep_priority.html">DB_ENV-&gt;rep_set_priority</a></td><td>Configure replication site priority</td></tr>
<!--DbEnv::rep_set_request--><tr><td><a href="../../api_c/rep_request.html">DB_ENV-&gt;rep_set_request</a></td><td>Configure replication client retransmission requests</td></tr>
<!--DbEnv::rep_set_timeout--><tr><td><a href="../../api_c/rep_timeout.html">DB_ENV-&gt;rep_set_timeout</a></td><td>Configure replication timeouts</td></tr>
<!--DbEnv::rep_set_transport--><tr><td><a href="../../api_c/rep_transport.html">DB_ENV-&gt;rep_set_transport</a></td><td>Configure replication transport callback</td></tr>
</table>
<table width="100%"><tr><td><br></td><td align=right><a href="../transapp/faq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../rep/id.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>