File: rep.html

package info (click to toggle)
db4.8 4.8.30-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 112,668 kB
  • ctags: 53,848
  • sloc: ansic: 177,324; java: 66,060; tcl: 61,580; cs: 27,778; cpp: 24,761; sh: 15,649; perl: 14,013; xml: 8,309; makefile: 2,303; awk: 1,749; sql: 390; python: 26; php: 22; asm: 14
file content (464 lines) | stat: -rw-r--r-- 18,667 bytes parent folder | download | duplicates (2)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<?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>Chapter 12.  Berkeley DB Replication</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="index.html" title="Berkeley DB Programmer's Reference Guide" />
    <link rel="prev" href="transapp_faq.html" title="Transaction FAQ" />
    <link rel="next" href="rep_id.html" title="Replication environment IDs" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Chapter 12. 
		Berkeley DB Replication
        </th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="transapp_faq.html">Prev</a> </td>
          <th width="60%" align="center"> </th>
          <td width="20%" align="right"> <a accesskey="n" href="rep_id.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="chapter" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="rep"></a>Chapter 12. 
		Berkeley DB Replication
        </h2>
          </div>
        </div>
      </div>
      <div class="toc">
        <p>
          <b>Table of Contents</b>
        </p>
        <dl>
          <dt>
            <span class="sect1">
              <a href="rep.html#rep_intro">Replication introduction</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_id.html">Replication environment IDs</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_pri.html">Replication environment priorities</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_app.html">Building replicated applications</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_mgr_meth.html">Replication Manager methods</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_base_meth.html">Base API Methods</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_comm.html">Building the communications infrastructure</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_newsite.html">Connecting to a new site</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_mgrmulti.html">Running Replication Manager in multiple processes</a>
            </span>
          </dt>
          <dd>
            <dl>
              <dt>
                <span class="sect2">
                  <a href="rep_mgrmulti.html#id1614081">One replication process and multiple subordinate processes</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="rep_mgrmulti.html#id1614595">Persistence of network address configuration</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="rep_mgrmulti.html#id1614238">Programming considerations</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="rep_mgrmulti.html#id1614244">Handling failure</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="rep_mgrmulti.html#id1614767">Other miscellaneous rules</a>
                </span>
              </dt>
            </dl>
          </dd>
          <dt>
            <span class="sect1">
              <a href="rep_elect.html">Elections</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_mastersync.html">Synchronizing with a master</a>
            </span>
          </dt>
          <dd>
            <dl>
              <dt>
                <span class="sect2">
                  <a href="rep_mastersync.html#rep_delay_sync">Delaying client synchronization</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="rep_mastersync.html#rep_c2c_sync">Client-to-client synchronization</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="rep_mastersync.html#id1615013">Blocked client operations</a>
                </span>
              </dt>
              <dt>
                <span class="sect2">
                  <a href="rep_mastersync.html#id1615125">Clients too far out-of-date to synchronize</a>
                </span>
              </dt>
            </dl>
          </dd>
          <dt>
            <span class="sect1">
              <a href="rep_init.html">Initializing a new site</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_bulk.html">Bulk transfer</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_trans.html">Transactional guarantees</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_lease.html">Master Leases</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_clock_skew.html">Clock Skew</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_partition.html">Network partitions</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_faq.html">Replication FAQ</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_ex.html">Ex_rep: a replication example</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_ex_comm.html">Ex_rep_base: a TCP/IP based communication infrastructure</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="rep_ex_rq.html">Ex_rep_base: putting it all together</a>
            </span>
          </dt>
        </dl>
      </div>
      <div class="sect1" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h2 class="title" style="clear: both"><a id="rep_intro"></a>Replication introduction</h2>
            </div>
          </div>
        </div>
        <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
<span class="emphasis"><em>master</em></span> database environment and one or more <span class="emphasis"><em>client</em></span>
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 replication "Base APIs".  This
approach affords more flexibility, but requires the application to
provide some critical components:</p>
        <div class="orderedlist">
          <ol type="1">
            <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).</li>
            <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.</li>
            <li>The application is responsible for monitoring the status of the master
and clients, and identifying any unavailable database environments.</li>
            <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.</li>
          </ol>
        </div>
        <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 Base API applications.  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>
        <div class="informaltable">
          <table border="1" width="80%">
            <colgroup>
              <col />
              <col />
            </colgroup>
            <thead>
              <tr>
                <th>Replication Manager Methods</th>
                <th>Description</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>
                  <a href="../api_reference/C/repmgrremote_site.html" class="olink">DB_ENV-&gt;repmgr_add_remote_site()</a>
                </td>
                <td>Specify the Replication Manager's remote sites</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repmgrset_ack_policy.html" class="olink">DB_ENV-&gt;repmgr_set_ack_policy()</a>
                </td>
                <td>Specify the Replication Manager's client acknowledgement policy</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repmgrlocal_site.html" class="olink">DB_ENV-&gt;repmgr_set_local_site()</a>
                </td>
                <td>Specify the Replication Manager's local site</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repmgrsite_list.html" class="olink">DB_ENV-&gt;repmgr_site_list()</a>
                </td>
                <td>List the sites and their status</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repmgrstart.html" class="olink">DB_ENV-&gt;repmgr_start()</a>
                </td>
                <td>Start the Replication Manager</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repmgrstat.html" class="olink">DB_ENV-&gt;repmgr_stat()</a>
                </td>
                <td>Replication Manager statistics</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repmgrstat_print.html" class="olink">DB_ENV-&gt;repmgr_stat_print()</a>
                </td>
                <td>Print Replication Manager statistics</td>
              </tr>
              <tr>
                <td>
                  <span class="emphasis">
                    <em>Base API Methods</em>
                  </span>
                </td>
                <td> </td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repelect.html" class="olink">DB_ENV-&gt;rep_elect()</a>
                </td>
                <td>Hold a replication election</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repmessage.html" class="olink">DB_ENV-&gt;rep_process_message()</a>
                </td>
                <td>Process a replication message</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/reptransport.html" class="olink">DB_ENV-&gt;rep_set_transport()</a>
                </td>
                <td>Configure replication transport callback</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repstart.html" class="olink">DB_ENV-&gt;rep_start()</a>
                </td>
                <td>Start replication</td>
              </tr>
              <tr>
                <td>
                  <span class="emphasis">
                    <em>Additional Replication Methods</em>
                  </span>
                </td>
                <td> </td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repstat.html" class="olink">DB_ENV-&gt;rep_stat()</a>
                </td>
                <td>Replication statistics</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repstat_print.html" class="olink">DB_ENV-&gt;rep_stat_print()</a>
                </td>
                <td>Print replication statistics</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repsync.html" class="olink">DB_ENV-&gt;rep_sync()</a>
                </td>
                <td>Replication synchronization</td>
              </tr>
              <tr>
                <td>
                  <span class="emphasis">
                    <em>Replication Configuration</em>
                  </span>
                </td>
                <td> </td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repclockskew.html" class="olink">DB_ENV-&gt;rep_set_clockskew()</a>
                </td>
                <td>Configure master lease clock adjustment</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repconfig.html" class="olink">DB_ENV-&gt;rep_set_config()</a>
                </td>
                <td>Configure the replication subsystem</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repset_limit.html" class="olink">DB_ENV-&gt;rep_set_limit()</a>
                </td>
                <td>Limit data sent in response to a single message</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repnsites.html" class="olink">DB_ENV-&gt;rep_set_nsites()</a>
                </td>
                <td>Configure replication group site count</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/reppriority.html" class="olink">DB_ENV-&gt;rep_set_priority()</a>
                </td>
                <td>Configure replication site priority</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repset_request.html" class="olink">DB_ENV-&gt;rep_set_request()</a>
                </td>
                <td>Configure replication client retransmission requests</td>
              </tr>
              <tr>
                <td>
                  <a href="../api_reference/C/repset_timeout.html" class="olink">DB_ENV-&gt;rep_set_timeout()</a>
                </td>
                <td>Configure replication timeouts</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="transapp_faq.html">Prev</a> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right"> <a accesskey="n" href="rep_id.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Transaction FAQ </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Replication environment IDs</td>
        </tr>
      </table>
    </div>
  </body>
</html>