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>DB_ENV->repmgr_start()</title> 7 <link rel="stylesheet" href="apiReference.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 C API Reference" /> 10 <link rel="up" href="rep.html" title="Chapter��10.�� Replication Methods" /> 11 <link rel="prev" href="repmgrsite_list.html" title="DB_ENV->repmgr_site_list()" /> 12 <link rel="next" href="repmgrstat.html" title="DB_ENV->repmgr_stat()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->repmgr_start()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="repmgrsite_list.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��10.�� 23 Replication Methods 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="repmgrstat.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="repmgrstart"></a>DB_ENV->repmgr_start()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->repmgr_start(DB_ENV *env, int nthreads, u_int32_t flags); </pre> 42 <p> 43 The <code class="methodname">DB_ENV->repmgr_start()</code> method starts the Replication Manager. 44 </p> 45 <p> 46 There are two ways to build Berkeley DB replication applications: the 47 most common approach is to use the Berkeley DB library Replication 48 Manager, where the Berkeley DB library manages the 49 replication group, including network transport, all replication 50 message processing and acknowledgment, and group elections. 51 Applications using the Replication Manager generally make the 52 following calls: 53 </p> 54 <div class="orderedlist"> 55 <ol type="1"> 56 <li> 57 <p> 58 Call 59 <a class="xref" href="repmgrlocal_site.html" title="DB_ENV->repmgr_set_local_site()">DB_ENV->repmgr_set_local_site()</a> 60 to configure the local site in the replication group. 61 </p> 62 </li> 63 <li> 64 <p> 65 Call 66 <a class="xref" href="repmgrremote_site.html" title="DB_ENV->repmgr_add_remote_site()">DB_ENV->repmgr_add_remote_site()</a> 67 to configure the remote site(s) in the replication group. 68 </p> 69 </li> 70 <li> 71 <p> 72 Call 73 <a class="xref" href="repmgrset_ack_policy.html" title="DB_ENV->repmgr_set_ack_policy()">DB_ENV->repmgr_set_ack_policy()</a> 74 to configure the message acknowledgment policy which best supports the 75 replication group's transactional needs. 76 </p> 77 </li> 78 <li> 79 <p> 80 Call 81 <a class="xref" href="reppriority.html" title="DB_ENV->rep_set_priority()">DB_ENV->rep_set_priority()</a> 82 to configure the local site's election priority. 83 </p> 84 </li> 85 <li> 86 <p> 87 Call <code class="methodname">DB_ENV->repmgr_start()</code> to start the replication application. 88 </p> 89 </li> 90 </ol> 91 </div> 92 <p> 93 For more information on building Replication Manager applications, 94 please see the <em class="citetitle">Replication Getting Started Guide</em> 95 included in the Berkeley DB documentation. 96 </p> 97 <p> 98 Applications with special needs (for example, applications using 99 network protocols not supported by the Berkeley DB Replication 100 Manager), must perform additional configuration and call other 101 Berkeley DB replication Base API methods. For more information on building 102 Base API applications, please see the 103 <a href="../../programmer_reference/rep_base_meth.html" class="olink">Base API Methods</a> section in the 104 <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>. 105 </p> 106 <p> 107 Starting the Replication Manager consists of opening the TCP/IP listening socket to accept 108 incoming connections, and starting all necessary background threads. When multiple processes 109 share a database environment, only one process can open the listening socket; the 110 <code class="methodname">DB_ENV->repmgr_start()</code> method automatically opens the socket in the 111 first process to call it, and skips this step in the later calls from other processes. 112 </p> 113 <p> 114 The <code class="methodname">DB_ENV->repmgr_start()</code> method 115 may not be called before the <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method is 116 called to open the local environment and the 117<a class="xref" href="repmgrlocal_site.html" title="DB_ENV->repmgr_set_local_site()">DB_ENV->repmgr_set_local_site()</a> 118 method is called to configure the local site. 119In addition, the local environment must be opened with the 120 <a class="link" href="envopen.html#envopen_DB_THREAD">DB_THREAD</a> 121flag set. 122 </p> 123 <p> 124 The <code class="methodname">DB_ENV->repmgr_start()</code> method will return 125 <code class="literal">DB_REP_IGNORE</code> 126 as an informational, non-error return code, if another process has previously become the 127 TCP/IP listener (though the current call has nevertheless successfully started Replication 128 Manager's background threads). Unless otherwise specified, the 129 <code class="methodname">DB_ENV->repmgr_start()</code> <span> 130 <span> 131 method returns a non-zero error value on failure and 0 on success. 132 </span> 133 134 </span> 135 </p> 136 <div class="sect2" lang="en" xml:lang="en"> 137 <div class="titlepage"> 138 <div> 139 <div> 140 <h3 class="title"><a id="id1703549"></a>Parameters</h3> 141 </div> 142 </div> 143 </div> 144 <div class="sect3" lang="en" xml:lang="en"> 145 <div class="titlepage"> 146 <div> 147 <div> 148 <h4 class="title"><a id="id1703607"></a>flags</h4> 149 </div> 150 </div> 151 </div> 152 <p> 153 The <span class="bold"><strong>flags</strong></span> parameter must be set to 154 one of the following values: 155 </p> 156 <div class="itemizedlist"> 157 <ul type="disc"> 158 <li> 159 <p><a id="repmgrstart_DB_REP_MASTER"></a> 160 <code class="literal">DB_REP_MASTER</code> 161 </p> 162 <p> 163 Start as a master site, and do not call for an election. Note there 164 must never be more than a single master in any replication group, and 165 only one site at a time should ever be started with the DB_REP_MASTER 166 flag specified. 167 </p> 168 </li> 169 <li> 170 <p><a id="repmgrstart_DB_REP_CLIENT"></a> 171 <code class="literal">DB_REP_CLIENT</code> 172 </p> 173 <p> 174 Start as a client site, and do not call for an election. 175 </p> 176 </li> 177 <li> 178 <p> 179 <code class="literal">DB_REP_ELECTION</code> 180 </p> 181 <p> 182 Start as a client, and call for an election if no master is found. 183 </p> 184 </li> 185 </ul> 186 </div> 187 </div> 188 <div class="sect3" lang="en" xml:lang="en"> 189 <div class="titlepage"> 190 <div> 191 <div> 192 <h4 class="title"><a id="id1703952"></a>nthreads</h4> 193 </div> 194 </div> 195 </div> 196 <p> 197 Specify the number of threads of control created and dedicated to 198 processing replication messages. In addition to these message 199 processing threads, the Replication Manager creates and manages a few 200 of its own threads of control. 201 </p> 202 </div> 203 </div> 204 <div class="sect2" lang="en" xml:lang="en"> 205 <div class="titlepage"> 206 <div> 207 <div> 208 <h3 class="title"><a id="id1703973"></a>Errors</h3> 209 </div> 210 </div> 211 </div> 212 <p> 213 The <code class="methodname">DB_ENV->repmgr_start()</code> <span> 214 <span> 215 method may fail and return one of the following non-zero errors: 216 </span> 217 218 </span> 219 </p> 220 <div class="sect3" lang="en" xml:lang="en"> 221 <div class="titlepage"> 222 <div> 223 <div> 224 <h4 class="title"><a id="id1703807"></a>EINVAL</h4> 225 </div> 226 </div> 227 </div> 228 <p> 229 If the database environment was not already opened or was 230opened without the <code class="literal">DB_THREAD</code> flag set; a local 231 site has not already been configured, this method is called 232 from a Base API application; or if an invalid 233 flag value or parameter was specified. 234 </p> 235 </div> 236 </div> 237 <div class="sect2" lang="en" xml:lang="en"> 238 <div class="titlepage"> 239 <div> 240 <div> 241 <h3 class="title"><a id="id1703808"></a>Class</h3> 242 </div> 243 </div> 244 </div> 245 <p> 246 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> 247 </p> 248 </div> 249 <div class="sect2" lang="en" xml:lang="en"> 250 <div class="titlepage"> 251 <div> 252 <div> 253 <h3 class="title"><a id="id1703982"></a>See Also</h3> 254 </div> 255 </div> 256 </div> 257 <p> 258 <a class="xref" href="rep.html#replist" title="Replication and Related Methods">Replication and Related Methods</a> 259 </p> 260 </div> 261 </div> 262 <div class="navfooter"> 263 <hr /> 264 <table width="100%" summary="Navigation footer"> 265 <tr> 266 <td width="40%" align="left"><a accesskey="p" href="repmgrsite_list.html">Prev</a>��</td> 267 <td width="20%" align="center"> 268 <a accesskey="u" href="rep.html">Up</a> 269 </td> 270 <td width="40%" align="right">��<a accesskey="n" href="repmgrstat.html">Next</a></td> 271 </tr> 272 <tr> 273 <td width="40%" align="left" valign="top">DB_ENV->repmgr_site_list()��</td> 274 <td width="20%" align="center"> 275 <a accesskey="h" href="index.html">Home</a> 276 </td> 277 <td width="40%" align="right" valign="top">��DB_ENV->repmgr_stat()</td> 278 </tr> 279 </table> 280 </div> 281 </body> 282</html> 283