1<!--$Id: intro.so,v 1.12 2007/12/15 01:15:54 alanb Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB Reference Guide: Replication introduction</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<a name="2"><!--meow--></a> 12<table width="100%"><tr valign=top> 13<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Replication</dl></b></td> 14<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> 15</td></tr></table> 16<p align=center><b>Replication introduction</b></p> 17<p>Berkeley DB includes support for building highly available applications based 18on replication. Berkeley DB replication groups consist of some number of 19independently configured database environments. There is a single 20<i>master</i> database environment and one or more <i>client</i> 21database environments. Master environments support both database reads 22and writes; client environments support only database reads. If the 23master environment fails, applications may upgrade a client to be the 24new master. The database environments might be on separate computers, 25on separate hardware partitions in a non-uniform memory access (NUMA) 26system, or on separate disks in a single server. 27As always with Berkeley DB environments, any number of 28concurrent processes or threads may access a database environment. In 29the case of a master environment, any number of threads of control may 30read and write the environment, and in the case of a client environment, 31any number of threads of control may read the environment.</p> 32<p>Applications may be written to provide various degrees of consistency 33between the master and clients. The system can be run synchronously 34such that replicas are guaranteed to be up-to-date with all committed 35transactions, but doing so may incur a significant performance penalty. 36Higher performance solutions sacrifice total consistency, allowing the 37clients to be out of date for an application-controlled amount of 38time.</p> 39<p>There are two ways to build replicated applications. The simpler way 40is to use the Berkeley DB Replication Manager. The Replication Manager 41provides a standard communications infrastructure, and it creates and 42manages the background threads needed for processing replication 43messages. (Note that in Replication Manager applications, all updates 44to databases at the master environment must be done through a single 45DB_ENV environment handle, though they may occur in multiple threads. 46This of course means that only a single process may update data.)</p> 47<p>The Replication Manager implementation is based on TCP/IP sockets, and 48uses POSIX 1003.1 style networking and thread support. (On Windows 49systems, it uses standard Windows thread support.) As a result, it is 50not as portable as the rest of the Berkeley DB library itself.</p> 51<p>The alternative is to use the lower-level "Base" replication API. This 52approach affords more flexibility, but requires the application to 53provide some critical components:</p> 54<ol> 55<p><li>A communication infrastructure. Applications may use whatever wire 56protocol is appropriate for their application (for example, RPC, TCP/IP, 57UDP, VI or message-passing over the backplane). 58<p><li>The application is responsible for naming. Berkeley DB refers to the members 59of a replication group using an application-provided ID, and 60applications must map that ID to a particular database environment or 61communication channel. 62<p><li>The application is responsible for monitoring the status of the master 63and clients, and identifying any unavailable database environments. 64<p><li>The application must provide whatever security policies are needed. 65For example, the application may choose to encrypt data, use a secure 66socket layer, or do nothing at all. The level of security is left to 67the sole discretion of the application. 68</ol> 69<p>(Note that Replication Manager does not provide wire security for 70replication messages.)</p> 71<p>The following pages present various programming considerations, many of 72which are directly relevant only for applications which use the Base 73replication API. However, even when using Replication Manager it is 74important to understand the concepts.</p> 75<p>Finally, the Berkeley DB replication implementation has one other additional 76feature to increase application reliability. Replication in Berkeley DB is 77implemented to perform database updates using a different code path than 78the standard ones. This means operations that manage to crash the 79replication master due to a software bug will not necessarily also crash 80replication clients.</p> 81<!--$Id: m4.methods,v 1.12 2007/10/26 15:43:11 bostic Exp $--> 82<table border=1 align=center> 83<tr><th>Replication Manager Methods</th><th>Description</th></tr> 84<!--DbEnv::repmgr_add_remote_site--><tr><td><a href="../../api_c/repmgr_remote_site.html">DB_ENV->repmgr_add_remote_site</a></td><td>Specify the replication manager's remote sites</td></tr> 85<!--DbEnv::repmgr_set_ack_policy--><tr><td><a href="../../api_c/repmgr_ack_policy.html">DB_ENV->repmgr_set_ack_policy</a></td><td>Specify the replication manager's client acknowledgement policy</td></tr> 86<!--DbEnv::repmgr_set_local_site--><tr><td><a href="../../api_c/repmgr_local_site.html">DB_ENV->repmgr_set_local_site</a></td><td>Specify the replication manager's local site</td></tr> 87<!--DbEnv::repmgr_site_list--><tr><td><a href="../../api_c/repmgr_site_list.html">DB_ENV->repmgr_site_list</a></td><td>List the sites and their status</td></tr> 88<!--DbEnv::repmgr_start--><tr><td><a href="../../api_c/repmgr_start.html">DB_ENV->repmgr_start</a></td><td>Start the replication manager</td></tr> 89<!--DbEnv::repmgr_stat--><tr><td><a href="../../api_c/repmgr_stat.html">DB_ENV->repmgr_stat</a></td><td>Replication manager statistics</td></tr> 90<tr><th>Base Replication API</th><th><br></th></tr> 91<!--DbEnv::rep_elect--><tr><td><a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a></td><td>Hold a replication election</td></tr> 92<!--DbEnv::rep_process_message--><tr><td><a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a></td><td>Process a replication message</td></tr> 93<!--DbEnv::rep_start--><tr><td><a href="../../api_c/rep_start.html">DB_ENV->rep_start</a></td><td>Configure an environment for replication</td></tr> 94<tr><th>Additional Replication Methods</th><th><br></th></tr> 95<!--DbEnv::rep_stat--><tr><td><a href="../../api_c/rep_stat.html">DB_ENV->rep_stat</a></td><td>Replication statistics</td></tr> 96<!--DbEnv::rep_sync--><tr><td><a href="../../api_c/rep_sync.html">DB_ENV->rep_sync</a></td><td>Replication synchronization</td></tr> 97<tr><th>Replication Configuration</th><th><br></th></tr> 98<!--DbEnv::rep_set_config--><tr><td><a href="../../api_c/rep_config.html">DB_ENV->rep_set_config</a></td><td>Configure the replication subsystem</td></tr> 99<!--DbEnv::rep_set_clockskew--><tr><td><a href="../../api_c/rep_clockskew.html">DB_ENV->rep_set_clockskew</a></td><td>Configure master lease clock adjustment</td></tr> 100<!--DbEnv::rep_set_limit--><tr><td><a href="../../api_c/rep_limit.html">DB_ENV->rep_set_limit</a></td><td>Limit data sent in response to a single message</td></tr> 101<!--DbEnv::rep_set_nsites--><tr><td><a href="../../api_c/rep_nsites.html">DB_ENV->rep_set_nsites</a></td><td>Configure replication group site count</td></tr> 102<!--DbEnv::rep_set_priority--><tr><td><a href="../../api_c/rep_priority.html">DB_ENV->rep_set_priority</a></td><td>Configure replication site priority</td></tr> 103<!--DbEnv::rep_set_request--><tr><td><a href="../../api_c/rep_request.html">DB_ENV->rep_set_request</a></td><td>Configure replication client retransmission requests</td></tr> 104<!--DbEnv::rep_set_timeout--><tr><td><a href="../../api_c/rep_timeout.html">DB_ENV->rep_set_timeout</a></td><td>Configure replication timeouts</td></tr> 105<!--DbEnv::rep_set_transport--><tr><td><a href="../../api_c/rep_transport.html">DB_ENV->rep_set_transport</a></td><td>Configure replication transport callback</td></tr> 106</table> 107<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> 108</td></tr></table> 109<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 110</body> 111</html> 112