| 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>Replication FAQ</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="rep.html" title="Chapter 12. Berkeley DB Replication" /> |
| 11 | <link rel="prev" href="rep_partition.html" title="Network partitions" /> |
| 12 | <link rel="next" href="rep_ex.html" title="Ex_rep: a replication example" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Replication FAQ</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="rep_partition.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 12. |
| 26 | Berkeley DB Replication |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="rep_ex.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="rep_faq"></a>Replication FAQ</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <div class="orderedlist"> |
| 42 | <ol type="1"> |
| 43 | <li> |
| 44 | <p> |
| 45 | <span class="bold"><strong>Does Berkeley DB provide support for |
| 46 | forwarding write queries from clients to |
| 47 | masters?</strong></span> |
| 48 | </p> |
| 49 | <p> |
| 50 | No, it does not. |
| 51 | |
| 52 | |
| 53 | |
| 54 | In general this protocol is left entirely to the application. |
| 55 | Note, there is no reason not to use the communications channels |
| 56 | a Base API application establishes for replication support to forward |
| 57 | database update messages to the master, since Berkeley DB does |
| 58 | not require those channels to be used exclusively for |
| 59 | replication messages. Replication Manager does not currently |
| 60 | offer this service to the application. |
| 61 | </p> |
| 62 | </li> |
| 63 | <li> |
| 64 | <p> |
| 65 | <span class="bold"><strong>Can I use replication to partition my |
| 66 | environment across multiple sites?</strong></span> |
| 67 | </p> |
| 68 | <p> |
| 69 | No, this is not possible. All replicated databases must be equally |
| 70 | shared by all environments in the replication group. |
| 71 | </p> |
| 72 | </li> |
| 73 | <li> |
| 74 | <p> |
| 75 | <span class="bold"><strong>I'm running with replication but I don't see my databases |
| 76 | on the client.</strong></span> |
| 77 | </p> |
| 78 | <p> |
| 79 | This problem may be the result of the application using absolute |
| 80 | path names for its databases, and the pathnames are not valid on |
| 81 | the client system. |
| 82 | </p> |
| 83 | </li> |
| 84 | <li> |
| 85 | <p> |
| 86 | <span class="bold"><strong>How can I distinguish Berkeley DB messages from application messages?</strong></span> |
| 87 | </p> |
| 88 | <p> |
| 89 | There is no way to distinguish Berkeley DB messages from |
| 90 | application-specific messages, nor does Berkeley DB offer any way |
| 91 | to wrap application messages inside of Berkeley DB messages. |
| 92 | Distributed applications exchanging their own messages should |
| 93 | either enclose Berkeley DB messages in their own wrappers, or use |
| 94 | separate network connections to send and receive Berkeley DB |
| 95 | messages. The one exception to this rule is connection information |
| 96 | for new sites; Berkeley DB offers a simple method for sites joining |
| 97 | replication groups to send connection information to the other |
| 98 | database environments in the group (see <a class="xref" href="rep_newsite.html" title="Connecting to a new site">Connecting to a new site</a> for more information). |
| 99 | </p> |
| 100 | </li> |
| 101 | <li> |
| 102 | <p> |
| 103 | <span class="bold"><strong>How should I build my <span class="bold"><strong>send</strong></span> function?</strong></span> |
| 104 | </p> |
| 105 | <p> |
| 106 | This depends on the specifics of the application. One common way |
| 107 | is to write the <span class="bold"><strong>rec</strong></span> and <span class="bold"><strong>control</strong></span> arguments' sizes and data to a |
| 108 | socket connected to each remote site. On a fast, local area net, |
| 109 | the simplest method is likely to be to construct broadcast |
| 110 | messages. Each Berkeley DB message would be encapsulated inside an |
| 111 | application specific message, with header information specifying |
| 112 | the intended recipient(s) for the message. This will likely |
| 113 | require a global numbering scheme, however, as the Berkeley DB |
| 114 | library has to be able to send specific log records to clients |
| 115 | apart from the general broadcast of new log records intended for |
| 116 | all members of a replication group. |
| 117 | </p> |
| 118 | </li> |
| 119 | <li> |
| 120 | <p> |
| 121 | <span class="bold"><strong>Does every one of my threads of control on |
| 122 | the master have to set up its own connection to every client? |
| 123 | And, does every one of my threads of control on the client have |
| 124 | to set up its own connection to every master?</strong></span> |
| 125 | </p> |
| 126 | <p> |
| 127 | This is not always necessary. In the Berkeley DB replication |
| 128 | model, any thread of control which modifies a database in the |
| 129 | master environment must be prepared to send a message to the client |
| 130 | environments, and any thread of control which delivers a message to |
| 131 | a client environment must be prepared to send a message to the |
| 132 | master. There are many ways in which these requirements can be |
| 133 | satisfied. |
| 134 | </p> |
| 135 | <p> |
| 136 | The simplest case is probably a single, multithreaded process |
| 137 | running on the master and clients. The process running on the |
| 138 | master would require a single write connection to each client and a |
| 139 | single read connection from each client. A process running on each |
| 140 | client would require a single read connection from the master and a |
| 141 | single write connection to the master. Threads running in these |
| 142 | processes on the master and clients would use the same network |
| 143 | connections to pass messages back and forth. |
| 144 | </p> |
| 145 | <p> |
| 146 | A common complication is when there are multiple processes running |
| 147 | on the master and clients. A straight-forward solution is to |
| 148 | increase the numbers of connections on the master — each |
| 149 | process running on the master has its own write connection to each |
| 150 | client. However, this requires only one additional connection for |
| 151 | each possible client in the master process. The master environment |
| 152 | still requires only a single read connection from each client (this |
| 153 | can be done by allocating a separate thread of control which does |
| 154 | nothing other than receive client messages and forward them into |
| 155 | the database). Similarly, each client still only requires a single |
| 156 | thread of control that receives master messages and forwards them |
| 157 | into the database, and which also takes database messages and |
| 158 | forwards them back to the master. This model requires the |
| 159 | networking infrastructure support many-to-one writers-to-readers, |
| 160 | of course. |
| 161 | </p> |
| 162 | <p> |
| 163 | If the number of network connections is a problem in the |
| 164 | multiprocess model, and inter-process communication on the system |
| 165 | is inexpensive enough, an alternative is have a single process |
| 166 | which communicates between the master and each client, and whenever |
| 167 | a process' <span class="bold"><strong>send</strong></span> function is |
| 168 | called, the process passes the message to the communications |
| 169 | process which is responsible for forwarding the message to the |
| 170 | appropriate client. Alternatively, a broadcast mechanism will |
| 171 | simplify the entire networking infrastructure, as processes will |
| 172 | likely no longer have to maintain their own specific network |
| 173 | connections. |
| 174 | </p> |
| 175 | </li> |
| 176 | </ol> |
| 177 | </div> |
| 178 | </div> |
| 179 | <div class="navfooter"> |
| 180 | <hr /> |
| 181 | <table width="100%" summary="Navigation footer"> |
| 182 | <tr> |
| 183 | <td width="40%" align="left"><a accesskey="p" href="rep_partition.html">Prev</a> </td> |
| 184 | <td width="20%" align="center"> |
| 185 | <a accesskey="u" href="rep.html">Up</a> |
| 186 | </td> |
| 187 | <td width="40%" align="right"> <a accesskey="n" href="rep_ex.html">Next</a></td> |
| 188 | </tr> |
| 189 | <tr> |
| 190 | <td width="40%" align="left" valign="top">Network partitions </td> |
| 191 | <td width="20%" align="center"> |
| 192 | <a accesskey="h" href="index.html">Home</a> |
| 193 | </td> |
| 194 | <td width="40%" align="right" valign="top"> Ex_rep: a replication example</td> |
| 195 | </tr> |
| 196 | </table> |
| 197 | </div> |
| 198 | </body> |
| 199 | </html> |