Debian Codegraph @

docs/api_reference/CXX/repmgrstart.html

raw symbols SCIP
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>DbEnv::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 11.  Replication Methods" />
11 <link rel="prev" href="repmgrsite_list.html" title="DbEnv::repmgr_site_list()" />
12 <link rel="next" href="repmgrstat.html" title="DbEnv::repmgr_stat()" />
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">DbEnv::repmgr_start()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="repmgrsite_list.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 11. 
26 Replication Methods
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="repmgrstat.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="repmgrstart"></a>DbEnv::repmgr_start()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 DbEnv::repmgr_start(int nthreads, u_int32_t flags);</pre>
45 <p>
46 The <code class="methodname">DbEnv::repmgr_start()</code> method starts the Replication Manager.
47 </p>
48 <p>
49 There are two ways to build Berkeley DB replication applications: the
50 most common approach is to use the Berkeley DB library Replication
51 Manager, where the Berkeley DB library manages the
52 replication group, including network transport, all replication
53 message processing and acknowledgment, and group elections.
54 Applications using the Replication Manager generally make the
55 following calls:
56 </p>
57 <div class="orderedlist">
58 <ol type="1">
59 <li>
60 <p>
61 Use <a class="xref" href="repmgr_site.html" title="DbEnv::repmgr_site()">DbEnv::repmgr_site()</a>
62 to obtain a DbSite handle, then use that handle to
63 configure the sites in your replication group.
64 </p>
65 <div class="orderedlist">
66 <ol type="a">
67 <li>
68 <p>
69 Use <a class="xref" href="dbsite_set_config.html" title="DbSite::set_config()">DbSite::set_config()</a>
70 to configure sites in your replication group.
71 </p>
72 </li>
73 <li>
74 <p>
75 Use <a class="xref" href="dbsite_remove.html" title="DbSite::remove()">DbSite::remove()</a>
76 to remove a site from the replication group.
77 </p>
78 </li>
79 </ol>
80 </div>
81 </li>
82 <li>
83 <p>
84 Call
85 <a class="xref" href="repmgrset_ack_policy.html" title="DbEnv::repmgr_set_ack_policy()">DbEnv::repmgr_set_ack_policy()</a>
86 to configure the message acknowledgment policy which best supports the
87 replication group's transactional needs.
88 </p>
89 </li>
90 <li>
91 <p>
92 Call
93 <a class="xref" href="reppriority.html" title="DbEnv::rep_set_priority()">DbEnv::rep_set_priority()</a>
94 to configure the local site's election priority.
95 </p>
96 </li>
97 <li>
98 <p>
99 Call <code class="methodname">DbEnv::repmgr_start()</code> to start the replication application.
100 </p>
101 </li>
102 </ol>
103 </div>
104 <p>
105 For more information on building Replication Manager applications,
106 please see the <em class="citetitle">Replication Getting Started Guide</em>
107 included in the Berkeley DB documentation.
108 </p>
109 <p>
110 Applications with special needs (for example, applications using
111 network protocols not supported by the Berkeley DB Replication
112 Manager), must perform additional configuration and call other
113 Berkeley DB replication Base API methods. For more information on building
114 Base API applications, please see the
115 <a href="../../programmer_reference/rep_base_meth.html" class="olink">Base API Methods</a> section in the
116 <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>.
117 </p>
118 <p>
119 Starting the Replication Manager consists of opening the TCP/IP listening socket to accept
120 incoming connections, and starting all necessary background threads. When multiple processes
121 share a database environment, only one process can open the listening socket; the
122 <code class="methodname">DbEnv::repmgr_start()</code> method automatically opens the socket in the
123 first process to call it, and skips this step in the later calls from other processes.
124 </p>
125 <p>
126 The <code class="methodname">DbEnv::repmgr_start()</code> method
127 may not be called before the <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is
128 called to open. In addition, this method may not be called before
129 your replication sites have been configured using the
130 <a class="link" href="db_site.html" title="The DbSite Handle">DbSite</a> class.
131 In addition, the local environment must be opened with the
132 <a class="link" href="envopen.html#envopen_DB_THREAD">DB_THREAD</a>
133 flag set.
134 </p>
135 <p>
136 The <code class="methodname">DbEnv::repmgr_start()</code> method will return
137 <code class="literal">DB_REP_IGNORE</code>
138 as an informational, non-error return code, if another process has previously become the
139 TCP/IP listener (though the current call has nevertheless successfully started Replication
140 Manager's background threads). Unless otherwise specified, the
141 <code class="methodname">DbEnv::repmgr_start()</code> <span>
142
143 <span>
144 method either returns a non-zero error value or throws an
145 exception that encapsulates a non-zero error value on
146 failure, and returns 0 on success.
147 </span>
148 </span>
149 </p>
150 <div class="sect2" lang="en" xml:lang="en">
151 <div class="titlepage">
152 <div>
153 <div>
154 <h3 class="title"><a id="idp9960648"></a>Parameters</h3>
155 </div>
156 </div>
157 </div>
158 <div class="sect3" lang="en" xml:lang="en">
159 <div class="titlepage">
160 <div>
161 <div>
162 <h4 class="title"><a id="idp9967928"></a>nthreads</h4>
163 </div>
164 </div>
165 </div>
166 <p>
167 Specify the number of threads of control created and dedicated to
168 processing replication messages. In addition to these message
169 processing threads, the Replication Manager creates and manages a few
170 of its own threads of control. The TCP/IP listener
171 process can change this value after the Replication
172 Manager is started with a subsequent call to the
173 <code class="methodname">DbEnv::repmgr_start()</code> method.
174 </p>
175 </div>
176 <div class="sect3" lang="en" xml:lang="en">
177 <div class="titlepage">
178 <div>
179 <div>
180 <h4 class="title"><a id="idp9960328"></a>flags</h4>
181 </div>
182 </div>
183 </div>
184 <p>
185 The <span class="bold"><strong>flags</strong></span> parameter must be set to
186 one of the following values when first starting the
187 Replication Manager:
188 </p>
189 <div class="itemizedlist">
190 <ul type="disc">
191 <li>
192 <p><a id="repmgrstart_DB_REP_MASTER"></a>
193 <code class="literal">DB_REP_MASTER</code>
194 </p>
195 <p>
196 Start as a master site, and do not call for an election. Note there
197 must never be more than a single master in any replication group, and
198 only one site at a time should ever be started with the DB_REP_MASTER
199 flag specified.
200 </p>
201 </li>
202 <li>
203 <p><a id="repmgrstart_DB_REP_CLIENT"></a>
204 <code class="literal">DB_REP_CLIENT</code>
205 </p>
206 <p>
207 Start as a client site, and do not call for an election.
208 </p>
209 </li>
210 <li>
211 <p>
212 <code class="literal">DB_REP_ELECTION</code>
213 </p>
214 <p>
215 Start as a client, and call for an election if no master is found.
216 </p>
217 </li>
218 </ul>
219 </div>
220 <p>
221 If the Replication Manager is already started, a
222 <span class="bold"><strong>flags</strong></span> value of 0 can
223 be used when making a subsequent call to change the
224 value of <span class="bold"><strong>nthreads</strong></span>.
225 </p>
226 </div>
227 </div>
228 <div class="sect2" lang="en" xml:lang="en">
229 <div class="titlepage">
230 <div>
231 <div>
232 <h3 class="title"><a id="idp9964456"></a>Errors</h3>
233 </div>
234 </div>
235 </div>
236 <p>
237 The <code class="methodname">DbEnv::repmgr_start()</code> <span>
238
239 <span>
240 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
241 exception, encapsulating one of the following non-zero errors, or return one
242 of the following non-zero errors:
243 </span>
244 </span>
245 </p>
246 <div class="sect3" lang="en" xml:lang="en">
247 <div class="titlepage">
248 <div>
249 <div>
250 <h4 class="title"><a id="idp9970848"></a>DB_REP_UNAVAIL</h4>
251 </div>
252 </div>
253 </div>
254 <p>
255 The local site tried to join the group, but was unable to do
256 so for some reason (because a master site is not available,
257 or because insufficient replicas are running to acknowledge
258 the new site). When that happens the application should
259 pause and retry adding the site until it completes
260 successfully.
261 </p>
262 </div>
263 <div class="sect3" lang="en" xml:lang="en">
264 <div class="titlepage">
265 <div>
266 <div>
267 <h4 class="title"><a id="idp9982928"></a>EINVAL</h4>
268 </div>
269 </div>
270 </div>
271 <p>
272 If the database environment was not already opened or was
273 opened without the <code class="literal">DB_THREAD</code> flag set; a local
274 site has not already been configured, this method is called
275 from a Base API application; or if an invalid
276 flag value or parameter was specified.
277 </p>
278 </div>
279 </div>
280 <div class="sect2" lang="en" xml:lang="en">
281 <div class="titlepage">
282 <div>
283 <div>
284 <h3 class="title"><a id="idp9975408"></a>Class</h3>
285 </div>
286 </div>
287 </div>
288 <p>
289 <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a>
290 </p>
291 </div>
292 <div class="sect2" lang="en" xml:lang="en">
293 <div class="titlepage">
294 <div>
295 <div>
296 <h3 class="title"><a id="idp9978144"></a>See Also</h3>
297 </div>
298 </div>
299 </div>
300 <p>
301 <a class="xref" href="rep.html#replist" title="Replication and Related Methods">Replication and Related Methods</a>
302 </p>
303 </div>
304 </div>
305 <div class="navfooter">
306 <hr />
307 <table width="100%" summary="Navigation footer">
308 <tr>
309 <td width="40%" align="left"><a accesskey="p" href="repmgrsite_list.html">Prev</a> </td>
310 <td width="20%" align="center">
311 <a accesskey="u" href="rep.html">Up</a>
312 </td>
313 <td width="40%" align="right"> <a accesskey="n" href="repmgrstat.html">Next</a></td>
314 </tr>
315 <tr>
316 <td width="40%" align="left" valign="top">DbEnv::repmgr_site_list() </td>
317 <td width="20%" align="center">
318 <a accesskey="h" href="index.html">Home</a>
319 </td>
320 <td width="40%" align="right" valign="top"> DbEnv::repmgr_stat()</td>
321 </tr>
322 </table>
323 </div>
324 </body>
325 </html>