| 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>Ex_rep: a replication example</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_faq.html" title="Replication FAQ" /> |
| 12 | <link rel="next" href="rep_ex_comm.html" title="Ex_rep_base: a TCP/IP based communication infrastructure" /> |
| 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">Ex_rep: a replication example</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="rep_faq.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_comm.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_ex"></a>Ex_rep: a replication example</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p>Ex_rep, found in the <code class="filename">examples_c/ex_rep</code> subdirectory |
| 42 | of the Berkeley DB distribution, is a simple but complete demonstration of a |
| 43 | replicated application. The application is a mock stock ticker. The |
| 44 | master accepts a stock symbol and a numerical value as input, and |
| 45 | stores this information into a replicated database; either master or |
| 46 | clients can display the contents of the database, given an empty input |
| 47 | line.</p> |
| 48 | <p>There are two versions of the application: ex_rep_mgr uses Replication |
| 49 | Manager, while ex_rep_base uses the replication Base API. This is |
| 50 | intended to demonstrate that, while the basic function of the |
| 51 | application is the same in either case, the replication support |
| 52 | infrastructure differs markedly.</p> |
| 53 | <p>The communication infrastructure demonstrated with ex_rep_base has the |
| 54 | same dependencies on system networking and threading support as does |
| 55 | the Replication Manager (see the <a class="xref" href="rep.html#rep_intro" title="Replication introduction">Replication introduction</a>). The Makefile created by the standard UNIX |
| 56 | configuration will build the ex_rep examples on most platforms. Enter |
| 57 | "make ex_rep_mgr" and/or "make ex_rep_base" to build them.</p> |
| 58 | <p>The synopsis for both programs is as follows:</p> |
| 59 | <code class="literal">ex_rep_xxx <span class="bold"><strong>-h home</strong></span> <span class="bold"><strong>-l host:port</strong></span> [<span class="bold"><strong>-MC</strong></span>] [<span class="bold"><strong>-r host:port</strong></span>] [<span class="bold"><strong>-R host:port</strong></span>] [<span class="bold"><strong>-a all|quorum</strong></span>] [<span class="bold"><strong>-b</strong></span>] [<span class="bold"><strong>-n sites</strong></span>] [<span class="bold"><strong>-p priority</strong></span>] [<span class="bold"><strong>-v</strong></span>]</code> |
| 60 | <p> |
| 61 | where "ex_rep_xxx" is either "ex_rep_mgr" or "ex_rep_base". The only |
| 62 | difference is that: |
| 63 | </p> |
| 64 | <div class="itemizedlist"> |
| 65 | <ul type="disc"> |
| 66 | <li> |
| 67 | <p> |
| 68 | specifying <span class="bold"><strong>-M</strong></span> or |
| 69 | <span class="bold"><strong>-C</strong></span> is optional for ex_rep_mgr, |
| 70 | but one of these options must be specified for ex_rep_base. |
| 71 | </p> |
| 72 | </li> |
| 73 | <li> |
| 74 | <p> |
| 75 | The <span class="bold"><strong>-n</strong></span> option is not supported |
| 76 | supported by ex_rep_mgr. That option specifies the number of |
| 77 | nodes in the replication group. When you use the Replication |
| 78 | Manager, this number is automatically determined for you. |
| 79 | </p> |
| 80 | </li> |
| 81 | </ul> |
| 82 | </div> |
| 83 | <p> |
| 84 | The options apply to either version of the program except where noted. |
| 85 | They are as follows: |
| 86 | </p> |
| 87 | <div class="variablelist"> |
| 88 | <dl> |
| 89 | <dt> |
| 90 | <span class="term"> |
| 91 | <span class="bold"> |
| 92 | <strong>-h</strong> |
| 93 | </span> |
| 94 | </span> |
| 95 | </dt> |
| 96 | <dd>Specify a home directory for the database environment.</dd> |
| 97 | <dt> |
| 98 | <span class="term"> |
| 99 | <span class="bold"> |
| 100 | <strong>-l</strong> |
| 101 | </span> |
| 102 | </span> |
| 103 | </dt> |
| 104 | <dd>Listen on local host "host" at port "port" for incoming connections.</dd> |
| 105 | <dt> |
| 106 | <span class="term"> |
| 107 | <span class="bold"> |
| 108 | <strong>-M</strong> |
| 109 | </span> |
| 110 | </span> |
| 111 | </dt> |
| 112 | <dd>Configure this process as a master.</dd> |
| 113 | <dt> |
| 114 | <span class="term"> |
| 115 | <span class="bold"> |
| 116 | <strong>-C</strong> |
| 117 | </span> |
| 118 | </span> |
| 119 | </dt> |
| 120 | <dd>Configure this process as a client.</dd> |
| 121 | <dt> |
| 122 | <span class="term"> |
| 123 | <span class="bold"> |
| 124 | <strong>-r</strong> |
| 125 | </span> |
| 126 | </span> |
| 127 | </dt> |
| 128 | <dd> |
| 129 | Identifies the helper site used for joining the group. |
| 130 | </dd> |
| 131 | <dt> |
| 132 | <span class="term"> |
| 133 | <span class="bold"> |
| 134 | <strong>-R</strong> |
| 135 | </span> |
| 136 | </span> |
| 137 | </dt> |
| 138 | <dd> |
| 139 | Identifies a remote peer to be used for joining the group. This |
| 140 | peer is used for syncing purposes. See |
| 141 | <a class="xref" href="rep_mastersync.html#rep_c2c_sync" title="Client-to-client synchronization">Client-to-client synchronization</a> |
| 142 | for more information. |
| 143 | </dd> |
| 144 | <dt> |
| 145 | <span class="term"> |
| 146 | <span class="bold"> |
| 147 | <strong>-a</strong> |
| 148 | </span> |
| 149 | </span> |
| 150 | </dt> |
| 151 | <dd> |
| 152 | Specify repmgr acknowledgement policy of all or quorum. See |
| 153 | <a href="../api_reference/C/repmgrset_ack_policy.html" class="olink">DB_ENV->repmgr_set_ack_policy()</a> for more information (ex_rep_mgr |
| 154 | only.) |
| 155 | </dd> |
| 156 | <dt> |
| 157 | <span class="term"> |
| 158 | <span class="bold"> |
| 159 | <strong>-b</strong> |
| 160 | </span> |
| 161 | </span> |
| 162 | </dt> |
| 163 | <dd> |
| 164 | Indicates that bulk transfer should be used. See <a class="xref" href="rep_bulk.html" title="Bulk transfer">Bulk transfer</a> for more |
| 165 | information. |
| 166 | </dd> |
| 167 | <dt> |
| 168 | <span class="term"> |
| 169 | <span class="bold"> |
| 170 | <strong>-n</strong> |
| 171 | </span> |
| 172 | </span> |
| 173 | </dt> |
| 174 | <dd> |
| 175 | Specify the total number of sites in the replication group |
| 176 | (ex_rep_base only). |
| 177 | </dd> |
| 178 | <dt> |
| 179 | <span class="term"> |
| 180 | <span class="bold"> |
| 181 | <strong>-p</strong> |
| 182 | </span> |
| 183 | </span> |
| 184 | </dt> |
| 185 | <dd>Set the |
| 186 | election priority. See |
| 187 | <a class="xref" href="rep_elect.html" title="Elections">Elections</a> for more |
| 188 | information. |
| 189 | </dd> |
| 190 | <dt> |
| 191 | <span class="term"> |
| 192 | <span class="bold"> |
| 193 | <strong>-v</strong> |
| 194 | </span> |
| 195 | </span> |
| 196 | </dt> |
| 197 | <dd>Indicates that additional informational and debugging output should be enabled.</dd> |
| 198 | </dl> |
| 199 | </div> |
| 200 | <p>A typical ex_rep_mgr session begins with a command such as the |
| 201 | following, to start a master:</p> |
| 202 | <pre class="programlisting">ex_rep_mgr -M -p 100 -h DIR1 -l localhost:30100</pre> |
| 203 | <p>and several clients:</p> |
| 204 | <pre class="programlisting">ex_rep_mgr -C -p 50 -h DIR2 -l localhost:30101 -r localhost:30100 |
| 205 | ex_rep_mgr -C -p 10 -h DIR3 -l localhost:30102 -r localhost:30100 |
| 206 | ex_rep_mgr -C -p 0 -h DIR4 -l localhost:30103 -r localhost:30100</pre> |
| 207 | <p> |
| 208 | In this example, the client with home directory DIR4 can never become a |
| 209 | master (its priority is 0). Both of the other clients can become |
| 210 | masters, but the one with home directory DIR2 is preferred. Priorities |
| 211 | are assigned by the application and should reflect the desirability of |
| 212 | having particular clients take over as master in the case that the |
| 213 | master fails. |
| 214 | </p> |
| 215 | </div> |
| 216 | <div class="navfooter"> |
| 217 | <hr /> |
| 218 | <table width="100%" summary="Navigation footer"> |
| 219 | <tr> |
| 220 | <td width="40%" align="left"><a accesskey="p" href="rep_faq.html">Prev</a> </td> |
| 221 | <td width="20%" align="center"> |
| 222 | <a accesskey="u" href="rep.html">Up</a> |
| 223 | </td> |
| 224 | <td width="40%" align="right"> <a accesskey="n" href="rep_ex_comm.html">Next</a></td> |
| 225 | </tr> |
| 226 | <tr> |
| 227 | <td width="40%" align="left" valign="top">Replication FAQ </td> |
| 228 | <td width="20%" align="center"> |
| 229 | <a accesskey="h" href="index.html">Home</a> |
| 230 | </td> |
| 231 | <td width="40%" align="right" valign="top"> Ex_rep_base: a TCP/IP based communication infrastructure</td> |
| 232 | </tr> |
| 233 | </table> |
| 234 | </div> |
| 235 | </body> |
| 236 | </html> |