• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/db-4.8.30/docs/programmer_reference/
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>Chapter��12.�� Berkeley DB Replication</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="index.html" title="Berkeley DB Programmer's Reference Guide" />
11    <link rel="prev" href="transapp_faq.html" title="Transaction FAQ" />
12    <link rel="next" href="rep_id.html" title="Replication environment IDs" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Chapter��12.��
19		Berkeley DB Replication
20        </th>
21        </tr>
22        <tr>
23          <td width="20%" align="left"><a accesskey="p" href="transapp_faq.html">Prev</a>��</td>
24          <th width="60%" align="center">��</th>
25          <td width="20%" align="right">��<a accesskey="n" href="rep_id.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="chapter" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title"><a id="rep"></a>Chapter��12.��
35		Berkeley DB Replication
36        </h2>
37          </div>
38        </div>
39      </div>
40      <div class="toc">
41        <p>
42          <b>Table of Contents</b>
43        </p>
44        <dl>
45          <dt>
46            <span class="sect1">
47              <a href="rep.html#rep_intro">Replication introduction</a>
48            </span>
49          </dt>
50          <dt>
51            <span class="sect1">
52              <a href="rep_id.html">Replication environment IDs</a>
53            </span>
54          </dt>
55          <dt>
56            <span class="sect1">
57              <a href="rep_pri.html">Replication environment priorities</a>
58            </span>
59          </dt>
60          <dt>
61            <span class="sect1">
62              <a href="rep_app.html">Building replicated applications</a>
63            </span>
64          </dt>
65          <dt>
66            <span class="sect1">
67              <a href="rep_mgr_meth.html">Replication Manager methods</a>
68            </span>
69          </dt>
70          <dt>
71            <span class="sect1">
72              <a href="rep_base_meth.html">Base API Methods</a>
73            </span>
74          </dt>
75          <dt>
76            <span class="sect1">
77              <a href="rep_comm.html">Building the communications infrastructure</a>
78            </span>
79          </dt>
80          <dt>
81            <span class="sect1">
82              <a href="rep_newsite.html">Connecting to a new site</a>
83            </span>
84          </dt>
85          <dt>
86            <span class="sect1">
87              <a href="rep_mgrmulti.html">Running Replication Manager in multiple processes</a>
88            </span>
89          </dt>
90          <dd>
91            <dl>
92              <dt>
93                <span class="sect2">
94                  <a href="rep_mgrmulti.html#id1614081">One replication process and multiple subordinate processes</a>
95                </span>
96              </dt>
97              <dt>
98                <span class="sect2">
99                  <a href="rep_mgrmulti.html#id1614595">Persistence of network address configuration</a>
100                </span>
101              </dt>
102              <dt>
103                <span class="sect2">
104                  <a href="rep_mgrmulti.html#id1614238">Programming considerations</a>
105                </span>
106              </dt>
107              <dt>
108                <span class="sect2">
109                  <a href="rep_mgrmulti.html#id1614244">Handling failure</a>
110                </span>
111              </dt>
112              <dt>
113                <span class="sect2">
114                  <a href="rep_mgrmulti.html#id1614767">Other miscellaneous rules</a>
115                </span>
116              </dt>
117            </dl>
118          </dd>
119          <dt>
120            <span class="sect1">
121              <a href="rep_elect.html">Elections</a>
122            </span>
123          </dt>
124          <dt>
125            <span class="sect1">
126              <a href="rep_mastersync.html">Synchronizing with a master</a>
127            </span>
128          </dt>
129          <dd>
130            <dl>
131              <dt>
132                <span class="sect2">
133                  <a href="rep_mastersync.html#rep_delay_sync">Delaying client synchronization</a>
134                </span>
135              </dt>
136              <dt>
137                <span class="sect2">
138                  <a href="rep_mastersync.html#rep_c2c_sync">Client-to-client synchronization</a>
139                </span>
140              </dt>
141              <dt>
142                <span class="sect2">
143                  <a href="rep_mastersync.html#id1615013">Blocked client operations</a>
144                </span>
145              </dt>
146              <dt>
147                <span class="sect2">
148                  <a href="rep_mastersync.html#id1615125">Clients too far out-of-date to synchronize</a>
149                </span>
150              </dt>
151            </dl>
152          </dd>
153          <dt>
154            <span class="sect1">
155              <a href="rep_init.html">Initializing a new site</a>
156            </span>
157          </dt>
158          <dt>
159            <span class="sect1">
160              <a href="rep_bulk.html">Bulk transfer</a>
161            </span>
162          </dt>
163          <dt>
164            <span class="sect1">
165              <a href="rep_trans.html">Transactional guarantees</a>
166            </span>
167          </dt>
168          <dt>
169            <span class="sect1">
170              <a href="rep_lease.html">Master Leases</a>
171            </span>
172          </dt>
173          <dt>
174            <span class="sect1">
175              <a href="rep_clock_skew.html">Clock Skew</a>
176            </span>
177          </dt>
178          <dt>
179            <span class="sect1">
180              <a href="rep_partition.html">Network partitions</a>
181            </span>
182          </dt>
183          <dt>
184            <span class="sect1">
185              <a href="rep_faq.html">Replication FAQ</a>
186            </span>
187          </dt>
188          <dt>
189            <span class="sect1">
190              <a href="rep_ex.html">Ex_rep: a replication example</a>
191            </span>
192          </dt>
193          <dt>
194            <span class="sect1">
195              <a href="rep_ex_comm.html">Ex_rep_base: a TCP/IP based communication infrastructure</a>
196            </span>
197          </dt>
198          <dt>
199            <span class="sect1">
200              <a href="rep_ex_rq.html">Ex_rep_base: putting it all together</a>
201            </span>
202          </dt>
203        </dl>
204      </div>
205      <div class="sect1" lang="en" xml:lang="en">
206        <div class="titlepage">
207          <div>
208            <div>
209              <h2 class="title" style="clear: both"><a id="rep_intro"></a>Replication introduction</h2>
210            </div>
211          </div>
212        </div>
213        <p>Berkeley DB includes support for building highly available applications based
214on replication.  Berkeley DB replication groups consist of some number of
215independently configured database environments.  There is a single
216<span class="emphasis"><em>master</em></span> database environment and one or more <span class="emphasis"><em>client</em></span>
217database environments.  Master environments support both database reads
218and writes; client environments support only database reads.  If the
219master environment fails, applications may upgrade a client to be the
220new master.  The database environments might be on separate computers,
221on separate hardware partitions in a non-uniform memory access (NUMA)
222system, or on separate disks in a single server.
223As always with Berkeley DB environments, any number of
224concurrent processes or threads may access a database environment.  In
225the case of a master environment, any number of threads of control may
226read and write the environment, and in the case of a client environment,
227any number of threads of control may read the environment.</p>
228        <p>Applications may be written to provide various degrees of consistency
229between the master and clients.  The system can be run synchronously
230such that replicas are guaranteed to be up-to-date with all committed
231transactions, but doing so may incur a significant performance penalty.
232Higher performance solutions sacrifice total consistency, allowing the
233clients to be out of date for an application-controlled amount of
234time.</p>
235        <p>There are two ways to build replicated applications.  The simpler way
236is to use the Berkeley DB Replication Manager.  The Replication Manager
237provides a standard communications infrastructure, and it creates and
238manages the background threads needed for processing replication
239messages.  (Note that in Replication Manager applications, all updates
240to databases at the master environment must be done through a single
241DB_ENV environment handle, though they may occur in multiple threads.
242This of course means that only a single process may update data.)</p>
243        <p>The Replication Manager implementation is based on TCP/IP sockets, and
244uses POSIX 1003.1 style networking and thread support.  (On Windows
245systems, it uses standard Windows thread support.)  As a result, it is
246not as portable as the rest of the Berkeley DB library itself.</p>
247        <p>The alternative is to use the lower-level replication "Base APIs".  This
248approach affords more flexibility, but requires the application to
249provide some critical components:</p>
250        <div class="orderedlist">
251          <ol type="1">
252            <li>A communication infrastructure.  Applications may use whatever wire
253protocol is appropriate for their application (for example, RPC, TCP/IP,
254UDP, VI or message-passing over the backplane).</li>
255            <li>The application is responsible for naming.  Berkeley DB refers to the members
256of a replication group using an application-provided ID, and
257applications must map that ID to a particular database environment or
258communication channel.</li>
259            <li>The application is responsible for monitoring the status of the master
260and clients, and identifying any unavailable database environments.</li>
261            <li>The application must provide whatever security policies are needed.
262For example, the application may choose to encrypt data, use a secure
263socket layer, or do nothing at all.  The level of security is left to
264the sole discretion of the application.</li>
265          </ol>
266        </div>
267        <p>(Note that Replication Manager does not provide wire security for
268replication messages.)</p>
269        <p>The following pages present various programming considerations, many of
270which are directly relevant only for Base API applications.  However, even when using Replication Manager it is
271important to understand the concepts.</p>
272        <p>Finally, the Berkeley DB replication implementation has one other additional
273feature to increase application reliability.  Replication in Berkeley DB is
274implemented to perform database updates using a different code path than
275the standard ones.  This means operations that manage to crash the
276replication master due to a software bug will not necessarily also crash
277replication clients.</p>
278        <div class="informaltable">
279          <table border="1" width="80%">
280            <colgroup>
281              <col />
282              <col />
283            </colgroup>
284            <thead>
285              <tr>
286                <th>Replication Manager Methods</th>
287                <th>Description</th>
288              </tr>
289            </thead>
290            <tbody>
291              <tr>
292                <td>
293                  <a href="../api_reference/C/repmgrremote_site.html" class="olink">DB_ENV-&gt;repmgr_add_remote_site()</a>
294                </td>
295                <td>Specify the Replication Manager's remote sites</td>
296              </tr>
297              <tr>
298                <td>
299                  <a href="../api_reference/C/repmgrset_ack_policy.html" class="olink">DB_ENV-&gt;repmgr_set_ack_policy()</a>
300                </td>
301                <td>Specify the Replication Manager's client acknowledgement policy</td>
302              </tr>
303              <tr>
304                <td>
305                  <a href="../api_reference/C/repmgrlocal_site.html" class="olink">DB_ENV-&gt;repmgr_set_local_site()</a>
306                </td>
307                <td>Specify the Replication Manager's local site</td>
308              </tr>
309              <tr>
310                <td>
311                  <a href="../api_reference/C/repmgrsite_list.html" class="olink">DB_ENV-&gt;repmgr_site_list()</a>
312                </td>
313                <td>List the sites and their status</td>
314              </tr>
315              <tr>
316                <td>
317                  <a href="../api_reference/C/repmgrstart.html" class="olink">DB_ENV-&gt;repmgr_start()</a>
318                </td>
319                <td>Start the Replication Manager</td>
320              </tr>
321              <tr>
322                <td>
323                  <a href="../api_reference/C/repmgrstat.html" class="olink">DB_ENV-&gt;repmgr_stat()</a>
324                </td>
325                <td>Replication Manager statistics</td>
326              </tr>
327              <tr>
328                <td>
329                  <a href="../api_reference/C/repmgrstat_print.html" class="olink">DB_ENV-&gt;repmgr_stat_print()</a>
330                </td>
331                <td>Print Replication Manager statistics</td>
332              </tr>
333              <tr>
334                <td>
335                  <span class="emphasis">
336                    <em>Base API Methods</em>
337                  </span>
338                </td>
339                <td>��</td>
340              </tr>
341              <tr>
342                <td>
343                  <a href="../api_reference/C/repelect.html" class="olink">DB_ENV-&gt;rep_elect()</a>
344                </td>
345                <td>Hold a replication election</td>
346              </tr>
347              <tr>
348                <td>
349                  <a href="../api_reference/C/repmessage.html" class="olink">DB_ENV-&gt;rep_process_message()</a>
350                </td>
351                <td>Process a replication message</td>
352              </tr>
353              <tr>
354                <td>
355                  <a href="../api_reference/C/reptransport.html" class="olink">DB_ENV-&gt;rep_set_transport()</a>
356                </td>
357                <td>Configure replication transport callback</td>
358              </tr>
359              <tr>
360                <td>
361                  <a href="../api_reference/C/repstart.html" class="olink">DB_ENV-&gt;rep_start()</a>
362                </td>
363                <td>Start replication</td>
364              </tr>
365              <tr>
366                <td>
367                  <span class="emphasis">
368                    <em>Additional Replication Methods</em>
369                  </span>
370                </td>
371                <td>��</td>
372              </tr>
373              <tr>
374                <td>
375                  <a href="../api_reference/C/repstat.html" class="olink">DB_ENV-&gt;rep_stat()</a>
376                </td>
377                <td>Replication statistics</td>
378              </tr>
379              <tr>
380                <td>
381                  <a href="../api_reference/C/repstat_print.html" class="olink">DB_ENV-&gt;rep_stat_print()</a>
382                </td>
383                <td>Print replication statistics</td>
384              </tr>
385              <tr>
386                <td>
387                  <a href="../api_reference/C/repsync.html" class="olink">DB_ENV-&gt;rep_sync()</a>
388                </td>
389                <td>Replication synchronization</td>
390              </tr>
391              <tr>
392                <td>
393                  <span class="emphasis">
394                    <em>Replication Configuration</em>
395                  </span>
396                </td>
397                <td>��</td>
398              </tr>
399              <tr>
400                <td>
401                  <a href="../api_reference/C/repclockskew.html" class="olink">DB_ENV-&gt;rep_set_clockskew()</a>
402                </td>
403                <td>Configure master lease clock adjustment</td>
404              </tr>
405              <tr>
406                <td>
407                  <a href="../api_reference/C/repconfig.html" class="olink">DB_ENV-&gt;rep_set_config()</a>
408                </td>
409                <td>Configure the replication subsystem</td>
410              </tr>
411              <tr>
412                <td>
413                  <a href="../api_reference/C/repset_limit.html" class="olink">DB_ENV-&gt;rep_set_limit()</a>
414                </td>
415                <td>Limit data sent in response to a single message</td>
416              </tr>
417              <tr>
418                <td>
419                  <a href="../api_reference/C/repnsites.html" class="olink">DB_ENV-&gt;rep_set_nsites()</a>
420                </td>
421                <td>Configure replication group site count</td>
422              </tr>
423              <tr>
424                <td>
425                  <a href="../api_reference/C/reppriority.html" class="olink">DB_ENV-&gt;rep_set_priority()</a>
426                </td>
427                <td>Configure replication site priority</td>
428              </tr>
429              <tr>
430                <td>
431                  <a href="../api_reference/C/repset_request.html" class="olink">DB_ENV-&gt;rep_set_request()</a>
432                </td>
433                <td>Configure replication client retransmission requests</td>
434              </tr>
435              <tr>
436                <td>
437                  <a href="../api_reference/C/repset_timeout.html" class="olink">DB_ENV-&gt;rep_set_timeout()</a>
438                </td>
439                <td>Configure replication timeouts</td>
440              </tr>
441            </tbody>
442          </table>
443        </div>
444      </div>
445    </div>
446    <div class="navfooter">
447      <hr />
448      <table width="100%" summary="Navigation footer">
449        <tr>
450          <td width="40%" align="left"><a accesskey="p" href="transapp_faq.html">Prev</a>��</td>
451          <td width="20%" align="center">��</td>
452          <td width="40%" align="right">��<a accesskey="n" href="rep_id.html">Next</a></td>
453        </tr>
454        <tr>
455          <td width="40%" align="left" valign="top">Transaction FAQ��</td>
456          <td width="20%" align="center">
457            <a accesskey="h" href="index.html">Home</a>
458          </td>
459          <td width="40%" align="right" valign="top">��Replication environment IDs</td>
460        </tr>
461      </table>
462    </div>
463  </body>
464</html>
465