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
|
<!--Id: faq.so,v 1.6 2002/05/09 20:38:15 bostic Exp -->
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
<!--All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB Reference Guide: Replication FAQ</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Replication</dl></h3></td>
<td align=right><a href="../../ref/rep/partition.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/rep/ex.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p>
<h1 align=center>Replication FAQ</h1>
<p><ol>
<p><li><b>Does Berkeley DB provide support for forwarding write queries from
clients to masters?</b>
<p>No, it does not. The Berkeley DB RPC server code could be modified to support
this functionality, but in general this protocol is left entirely to
the application. Note, there is no reason not to use the communications
channels the application establishes for replication support to forward
database update messages to the master, Berkeley DB does not require that
those channels be used exclusively for replication messages.
<p><li><b>Can I use replication to partition my environment across
multiple sites?</b>
<p>No, this is not possible. All replicated databases must be equally
shared by all environments in the replication group.
<p><li><b>How can I distinguish Berkeley DB messages from application messages?</b>
<p>There is no way to distinguish Berkeley DB messages from application-specific
messages, nor does Berkeley DB offer any way to wrap application messages
inside of Berkeley DB messages. Distributed applications exchanging their
own messages should either enclose Berkeley DB messages in their own wrappers,
or use separate network connections to send and receive Berkeley DB messages.
The one exception to this rule is connection information for new sites;
Berkeley DB offers a simple method for sites joining replication groups to
send connection information to the other database environments in the
group (see <a href="../../ref/rep/newsite.html">Connecting to a new site</a>
for more information).
<p><li><b>How should I build my <b>send</b> function?</b>
<p>This depends on the specifics of the application. One common way is to
write the <b>rec</b> and <b>control</b> arguments' sizes and data to
a socket connected to each remote site. On a fast, local area net, the
simplest method is likely to be construct broadcast messages. Each
Berkeley DB message would be encapsulated inside an application specific
message, with header information specifying the intended recipient(s)
for the message. This will likely require a global numbering scheme,
however, as the Berkeley DB library has to be able to send specific log
records to clients apart from the general broadcast of new log records
intended for all members of a replication group.
<p><li><b>Does every one of my threads of control on the master have to
set up its own connection to every client? And, does every one of my
threads of control on the client have to set up its own connection to
every master?</b>
<p>This is not always necessary. In the Berkeley DB replication model, any
thread of control which modifies a database in the master environment
must be prepared to send a message to the client environments, and any
thread of control which delivers a message to a client environment must
be prepared to send a message to the master. There are many ways in
which these requirements can be satisfied.
<p>The simplest case is probably a single, multithreaded process running
on the master and clients. The process running on the master would
require a single write connection to each client and a single read
connection from each client. A process running on each client would
require a single read connection from the master and a single write
connection to the master. Threads running in these processes on the
master and clients would use the same network connections to pass
messages back and forth.
<p>A common complication is when there are multiple processes running on
the master and clients. A straight-forward solution is to increase the
numbers of connections on the master -- each process running on the
master has its own write connection to each client. However, this
requires only one additional connection for each possible client in the
master process. The master environment still requires only a single
read connection from each client (this can be done by allocating a
separate thread of control which does nothing other than receive client
messages and forward them into the database). Similarly, each client
still only requires a single thread of control that receives master
messages and forwards them into the database, and which also takes
database messages and forwards them back to the master. This model
requires the networking infrastructure support many-to-one
writers-to-readers, of course.
<p>If the number of network connections is a problem in the multiprocess
model, and inter-process communication on the system is inexpensive
enough, an alternative is have a single process which communicates
between the master the each client, and whenever a process'
<b>send</b> function is called, the process passes the message to the
communications process which is responsible for forwarding the message
to the appropriate client. Alternatively, a broadcast mechanism will
simplify the entire networking infrastructure, as processes will likely
no longer have to maintain their own specific network connections.
<p><li><b>Can I use replication to replicate just the database
environment's log files?</b>
<p>Yes. If the <a href="../../api_c/rep_start.html#DB_REP_LOGSONLY">DB_REP_LOGSONLY</a> flag is specified to
<a href="../../api_c/rep_start.html">DB_ENV->rep_start</a>, the client site acts as a repository for logfiles
(see <a href="../../ref/rep/logonly.html">Log file only clients</a> for more
information).
</ol>
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/partition.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/rep/ex.html"><img src="../../images/next.gif" alt="Next"></a>
</td></tr></table>
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
</body>
</html>
|