Debian Codegraph @

docs/api_reference/C/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>DB_ENV-&gt;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-&gt;repmgr_site_list()" />
12 <link rel="next" href="repmgrstat.html" title="DB_ENV-&gt;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">DB_ENV-&gt;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 10. 
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>DB_ENV-&gt;repmgr_start()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB_ENV-&gt;repmgr_start(DB_ENV *env, int nthreads, u_int32_t flags); </pre>
45 <p>
46 The <code class="methodname">DB_ENV-&gt;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="DB_ENV-&gt;repmgr_site()">DB_ENV-&gt;repmgr_site()</a>
62 to obtain a DB_SITE 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="DB_SITE-&gt;set_config()">DB_SITE-&gt;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="DB_SITE-&gt;remove()">DB_SITE-&gt;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="DB_ENV-&gt;repmgr_set_ack_policy()">DB_ENV-&gt;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="DB_ENV-&gt;rep_set_priority()">DB_ENV-&gt;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">DB_ENV-&gt;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">DB_ENV-&gt;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">DB_ENV-&gt;repmgr_start()</code> method
127 may not be called before the <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;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 DB_SITE Handle">DB_SITE</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">DB_ENV-&gt;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">DB_ENV-&gt;repmgr_start()</code> <span>
142 <span>
143 method returns a non-zero error value on failure and 0 on success.
144 </span>
145
146 </span>
147 </p>
148 <div class="sect2" lang="en" xml:lang="en">
149 <div class="titlepage">
150 <div>
151 <div>
152 <h3 class="title"><a id="idp54473552"></a>Parameters</h3>
153 </div>
154 </div>
155 </div>
156 <div class="sect3" lang="en" xml:lang="en">
157 <div class="titlepage">
158 <div>
159 <div>
160 <h4 class="title"><a id="idp54481264"></a>nthreads</h4>
161 </div>
162 </div>
163 </div>
164 <p>
165 Specify the number of threads of control created and dedicated to
166 processing replication messages. In addition to these message
167 processing threads, the Replication Manager creates and manages a few
168 of its own threads of control. The TCP/IP listener
169 process can change this value after the Replication
170 Manager is started with a subsequent call to the
171 <code class="methodname">DB_ENV-&gt;repmgr_start()</code> method.
172 </p>
173 </div>
174 <div class="sect3" lang="en" xml:lang="en">
175 <div class="titlepage">
176 <div>
177 <div>
178 <h4 class="title"><a id="idp54473448"></a>flags</h4>
179 </div>
180 </div>
181 </div>
182 <p>
183 The <span class="bold"><strong>flags</strong></span> parameter must be set to
184 one of the following values when first starting the
185 Replication Manager:
186 </p>
187 <div class="itemizedlist">
188 <ul type="disc">
189 <li>
190 <p><a id="repmgrstart_DB_REP_MASTER"></a>
191 <code class="literal">DB_REP_MASTER</code>
192 </p>
193 <p>
194 Start as a master site, and do not call for an election. Note there
195 must never be more than a single master in any replication group, and
196 only one site at a time should ever be started with the DB_REP_MASTER
197 flag specified.
198 </p>
199 </li>
200 <li>
201 <p><a id="repmgrstart_DB_REP_CLIENT"></a>
202 <code class="literal">DB_REP_CLIENT</code>
203 </p>
204 <p>
205 Start as a client site, and do not call for an election.
206 </p>
207 </li>
208 <li>
209 <p>
210 <code class="literal">DB_REP_ELECTION</code>
211 </p>
212 <p>
213 Start as a client, and call for an election if no master is found.
214 </p>
215 </li>
216 </ul>
217 </div>
218 <p>
219 If the Replication Manager is already started, a
220 <span class="bold"><strong>flags</strong></span> value of 0 can
221 be used when making a subsequent call to change the
222 value of <span class="bold"><strong>nthreads</strong></span>.
223 </p>
224 </div>
225 </div>
226 <div class="sect2" lang="en" xml:lang="en">
227 <div class="titlepage">
228 <div>
229 <div>
230 <h3 class="title"><a id="idp54477576"></a>Errors</h3>
231 </div>
232 </div>
233 </div>
234 <p>
235 The <code class="methodname">DB_ENV-&gt;repmgr_start()</code> <span>
236 <span>
237 method may fail and return one of the following non-zero errors:
238 </span>
239
240 </span>
241 </p>
242 <div class="sect3" lang="en" xml:lang="en">
243 <div class="titlepage">
244 <div>
245 <div>
246 <h4 class="title"><a id="idp54495072"></a>DB_REP_UNAVAIL</h4>
247 </div>
248 </div>
249 </div>
250 <p>
251 The local site tried to join the group, but was unable to do
252 so for some reason (because a master site is not available,
253 or because insufficient replicas are running to acknowledge
254 the new site). When that happens the application should
255 pause and retry adding the site until it completes
256 successfully.
257 </p>
258 </div>
259 <div class="sect3" lang="en" xml:lang="en">
260 <div class="titlepage">
261 <div>
262 <div>
263 <h4 class="title"><a id="idp54481752"></a>EINVAL</h4>
264 </div>
265 </div>
266 </div>
267 <p>
268 If the database environment was not already opened or was
269 opened without the <code class="literal">DB_THREAD</code> flag set; a local
270 site has not already been configured, this method is called
271 from a Base API application; or if an invalid
272 flag value or parameter was specified.
273 </p>
274 </div>
275 </div>
276 <div class="sect2" lang="en" xml:lang="en">
277 <div class="titlepage">
278 <div>
279 <div>
280 <h3 class="title"><a id="idp54496152"></a>Class</h3>
281 </div>
282 </div>
283 </div>
284 <p>
285 <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>
286 </p>
287 </div>
288 <div class="sect2" lang="en" xml:lang="en">
289 <div class="titlepage">
290 <div>
291 <div>
292 <h3 class="title"><a id="idp54491800"></a>See Also</h3>
293 </div>
294 </div>
295 </div>
296 <p>
297 <a class="xref" href="rep.html#replist" title="Replication and Related Methods">Replication and Related Methods</a>
298 </p>
299 </div>
300 </div>
301 <div class="navfooter">
302 <hr />
303 <table width="100%" summary="Navigation footer">
304 <tr>
305 <td width="40%" align="left"><a accesskey="p" href="repmgrsite_list.html">Prev</a> </td>
306 <td width="20%" align="center">
307 <a accesskey="u" href="rep.html">Up</a>
308 </td>
309 <td width="40%" align="right"> <a accesskey="n" href="repmgrstat.html">Next</a></td>
310 </tr>
311 <tr>
312 <td width="40%" align="left" valign="top">DB_ENV-&gt;repmgr_site_list() </td>
313 <td width="20%" align="center">
314 <a accesskey="h" href="index.html">Home</a>
315 </td>
316 <td width="40%" align="right" valign="top"> DB_ENV-&gt;repmgr_stat()</td>
317 </tr>
318 </table>
319 </div>
320 </body>
321 </html>