Debian Codegraph @

docs/programmer_reference/group_membership.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>Managing Replication Manager Group Membership</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_newsite.html" title="Connecting to a new site" />
12 <link rel="next" href="rep_filename.html" title="Managing Replication Files" />
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">Managing Replication Manager Group Membership</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="rep_newsite.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_filename.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="group_membership"></a>Managing Replication Manager Group Membership</h2>
38 </div>
39 </div>
40 </div>
41 <div class="toc">
42 <dl>
43 <dt>
44 <span class="sect2">
45 <a href="group_membership.html#group_mem_add">Adding Sites to a Replication Group</a>
46 </span>
47 </dt>
48 <dt>
49 <span class="sect2">
50 <a href="group_membership.html#group_mem_remove">Removing Sites from a Replication Group</a>
51 </span>
52 </dt>
53 <dt>
54 <span class="sect2">
55 <a href="group_membership.html#group_mem_primordialstartup">Primordial Startups</a>
56 </span>
57 </dt>
58 <dt>
59 <span class="sect2">
60 <a href="group_membership.html#group_mem_upgrade">Upgrading Groups</a>
61 </span>
62 </dt>
63 </dl>
64 </div>
65 <p>
66 A replication group is a collection of two or more database
67 environments which are configured to replicate with one another.
68 When operating normally, a replication group consists of a master
69 site and one or more read-only sites.
70 </p>
71 <p>
72 For Replication Manager applications, the sites comprising the
73 replication group are recorded in an internal database, so even if
74 a group member is not available, it counts towards the group's
75 total site count. This matters for certain replication activities,
76 such as holding elections and acknowledging replication messages
77 that require some number of sites to participate in these
78 activities. Replicated applications will often require all sites,
79 or a majority of sites, to participate before the activity can be
80 completed.
81 </p>
82 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
83 <h3 class="title">Note</h3>
84 <p>
85 If you are configuring your application to keep replication
86 metadata in-memory by specifying the <a href="../api_reference/C/repconfig.html#config_DB_REP_CONF_INMEM" class="olink">DB_REP_CONF_INMEM</a> flag to the
87 <a href="../api_reference/C/repconfig.html" class="olink">DB_ENV-&gt;rep_set_config()</a> method, then the internal database containing group
88 site information is not stored persistently on disk. This
89 severely limits Replication Manager's ability to automatically
90 manage group membership. For more information, including some
91 work-arounds, see
92 <a class="xref" href="rep_filename.html" title="Managing Replication Files">Managing Replication Files</a>.
93 </p>
94 </div>
95 <p>
96 Because Replication Manager tracks group members, there are some
97 administrative activities that you should know about when using BDB
98 replication.
99 </p>
100 <div class="sect2" lang="en" xml:lang="en">
101 <div class="titlepage">
102 <div>
103 <div>
104 <h3 class="title"><a id="group_mem_add"></a>Adding Sites to a Replication Group</h3>
105 </div>
106 </div>
107 </div>
108 <p>
109 To add a site to a replication group, you merely start up the
110 site such that it knows where at least one site in the group is
111 located. The site new site then joins the group. When this
112 happens, the new site is recorded in the Replication Manager's
113 group member database.
114 </p>
115 <p>
116 Note that when you are starting the very first site in the
117 group for the very first time (called <span class="emphasis"><em>the primordial
118 start up</em></span>), there are no other existing sites to
119 help the new site join the group. In fact, a primordial start up
120 actually creates the group. For this reason, there are some
121 slight differences on how to perform a primordial start up. For
122 a description of this, see
123 <a class="xref" href="group_membership.html#group_mem_primordialstartup" title="Primordial Startups">Primordial Startups</a>.
124 </p>
125 <p>
126 When you add a site to a replication group, you use the
127 following general procedure:
128 </p>
129 <div class="itemizedlist">
130 <ul type="disc">
131 <li>
132 <p>
133 Make sure your replication group is operating well
134 enough that write activity can occur.
135 </p>
136 </li>
137 <li>
138 <p>
139 Create and open the environment such that it is configured to
140 use replication.
141 </p>
142 </li>
143 <li>
144 <p>
145 Use <a href="../api_reference/C/repmgr_site.html" class="olink">DB_ENV-&gt;repmgr_site()</a> to obtain a <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle.
146 Configure this handle for the local site's host and
147 port information when you create the handle. Then, use
148 <a href="../api_reference/C/dbsite_set_config.html" class="olink">DB_SITE-&gt;set_config()</a> to indicate that this is the local
149 site by setting the <code class="literal">DB_LOCAL_SITE</code>
150 parameter.
151 </p>
152 </li>
153 <li>
154 <p>
155 Use <a href="../api_reference/C/repmgr_site.html" class="olink">DB_ENV-&gt;repmgr_site()</a> to obtain a second <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle.
156 Configure this handle with the host and port
157 information for a site that already belongs to the
158 replication group. Then, use <a href="../api_reference/C/dbsite_set_config.html" class="olink">DB_SITE-&gt;set_config()</a> to
159 indicate this site is a "helper" site by setting the
160 <code class="literal">DB_BOOTSTRAP_HELPER</code> parameter. By
161 configuring a <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle in this way, your new
162 site will know how to contact the replication group so
163 that it can join the group.
164 </p>
165 </li>
166 <li>
167 <p>
168 Start replication as normal by configuring an
169 acknowledgement policy, setting the site's replication
170 priority, and then calling <a href="../api_reference/C/repmgrstart.html" class="olink">DB_ENV-&gt;repmgr_start()</a>.
171 </p>
172 </li>
173 </ul>
174 </div>
175 <p>
176 Note that on subsequent start-ups of your replication code, any
177 helper site information you might provide is ignored because
178 the Replication Manager reads the group membership database
179 in order to obtain this information.
180 </p>
181 <p>
182 Also, be aware that if the new site cannot be added to the
183 group for some reason (because a master site is not available,
184 or because insufficient replicas are running to acknowledge the
185 new site), the attempt to start the new site via <a href="../api_reference/C/repmgrstart.html" class="olink">DB_ENV-&gt;repmgr_start()</a>
186 will fail and return <code class="literal">DB_REP_UNAVAIL</code>. You can
187 then pause and retry the start up attempt until it completes
188 successfully.
189 </p>
190 <p>
191 You must use the exact same host string and port number to refer
192 to a given site throughout your application and on each of its
193 sites.
194 </p>
195 </div>
196 <div class="sect2" lang="en" xml:lang="en">
197 <div class="titlepage">
198 <div>
199 <div>
200 <h3 class="title"><a id="group_mem_remove"></a>Removing Sites from a Replication Group</h3>
201 </div>
202 </div>
203 </div>
204 <p>
205 Elections and message acknowledgements require knowledge of the
206 total number of sites in the group. If a site is shut down, or
207 is otherwise unable to communicate with the rest of the group,
208 it still counts towards the total number of sites in the group.
209 In most cases, this is the desirable behavior.
210 </p>
211 <p>
212 However, if you are shutting down a site permanently, then you
213 should remove that site from the group. You might also want to
214 remove a site from the group if you are shutting it down
215 temporarily, but nevertheless for a very long period of time
216 (days or weeks). In either case, you remove a site from the
217 group by:
218 </p>
219 <div class="itemizedlist">
220 <ul type="disc">
221 <li>
222 <p>
223 Make sure your replication group is operating well
224 enough that write activity can occur.
225 </p>
226 </li>
227 <li>
228 <p>
229 On one of the sites in your replication group (this
230 does not have to be the master site), use <a href="../api_reference/C/repmgr_site.html" class="olink">DB_ENV-&gt;repmgr_site()</a>
231 to obtain a <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle. Configure this handle with
232 the host and port information of the site that you want
233 to remove.
234 </p>
235 <p>
236 Note that this step can occur at any site —
237 including the site that you are removing from the
238 group.
239 </p>
240 </li>
241 <li>
242 <p>
243 Call the <a href="../api_reference/C/dbsite_remove.html" class="olink">DB_SITE-&gt;remove()</a> method. This removes the
244 identified site from the replication group database. If
245 this action is not performed on the master site, the
246 client sends a request to the master to perform the
247 operation and awaits confirmation.
248 </p>
249 </li>
250 </ul>
251 </div>
252 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
253 <h3 class="title">Note</h3>
254 <p>
255 Upon completing the above procedure, DO NOT call the
256 <a href="../api_reference/C/dbsite_close.html" class="olink">DB_SITE-&gt;close()</a> method. After removing (or even attempting
257 to remove) a site from the group using a <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle,
258 the handle must never be accessed again.
259 </p>
260 </div>
261 </div>
262 <div class="sect2" lang="en" xml:lang="en">
263 <div class="titlepage">
264 <div>
265 <div>
266 <h3 class="title"><a id="group_mem_primordialstartup"></a>Primordial Startups</h3>
267 </div>
268 </div>
269 </div>
270 <p>
271 If you have never started a site in a replication group before,
272 then the replication group membership database does not exist.
273 In this situation, you must start the site and declare it to be
274 the group creator. This causes the site to become the master,
275 create the group membership database, and create a replication
276 group of size 1. After that, subsequent sites can add
277 themselves to the group as described in
278 <a class="xref" href="group_membership.html#group_mem_add" title="Adding Sites to a Replication Group">Adding Sites to a Replication Group</a>.
279 </p>
280 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
281 <h3 class="title">Note</h3>
282 <p>
283 It is never incorrect to declare a site the group creator.
284 This is true even well-after the replication group has been
285 established. This is because group creator information is
286 ignored on any site start-up, except for the primoridial
287 start-up; that is, a start-up where the group membership
288 database does not exist.
289 </p>
290 </div>
291 <p>
292 To declare a site as the group creator:
293 </p>
294 <div class="itemizedlist">
295 <ul type="disc">
296 <li>
297 <p>
298 Create and open the environment such that it is configured to
299 use replication.
300 </p>
301 </li>
302 <li>
303 <p>
304 Use <a href="../api_reference/C/repmgr_site.html" class="olink">DB_ENV-&gt;repmgr_site()</a> to obtain a <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle.
305 Configure this handle for the local site's host and
306 port information when you create the handle. Then, use
307 <a href="../api_reference/C/dbsite_set_config.html" class="olink">DB_SITE-&gt;set_config()</a> to indicate that this is the group
308 creator site by setting the <code class="literal">DB_GROUP_CREATOR</code>
309 parameter.
310 </p>
311 </li>
312 <li>
313 <p>
314 Start replication as normal by configuring
315 acknowledgement policies, setting replication
316 priorities for the site, and then calling
317 <a href="../api_reference/C/repmgrstart.html" class="olink">DB_ENV-&gt;repmgr_start()</a>.
318 </p>
319 </li>
320 </ul>
321 </div>
322 </div>
323 <div class="sect2" lang="en" xml:lang="en">
324 <div class="titlepage">
325 <div>
326 <div>
327 <h3 class="title"><a id="group_mem_upgrade"></a>Upgrading Groups</h3>
328 </div>
329 </div>
330 </div>
331 <p>
332 Prior to the Berkeley DB 11.2.5.2 release, replication group
333 membership was managed differently than in the way it is
334 described in the previous sections. For this reason, when you
335 upgrade from older releases of Berkeley DB to 11.2.5.2 or
336 later, the upgrade procedure is different than when upgrading
337 between other releases.
338 </p>
339 <p>
340 To perform an upgrade that takes you from the old way of
341 managing group membership to the new way of managing group
342 membership (pre-11.2.5.2 to 11.2.5.2 and later), do the
343 following:
344 </p>
345 <div class="itemizedlist">
346 <ul type="disc">
347 <li>
348 <p>
349 Update your replication code to use the new <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a>
350 handle and related methods. Recompile and thoroughly
351 test your code to make sure it is production-ready.
352 </p>
353 </li>
354 <li>
355 <p>
356 Do the following one production machine at a time. Make
357 sure to do this at the master site LAST.
358 </p>
359 <div class="orderedlist">
360 <ol type="1">
361 <li>
362 <p>
363 Shut down the old replication code.
364 </p>
365 </li>
366 <li>
367 <p>
368 Install the new replication code.
369 </p>
370 </li>
371 <li>
372 <p>
373 Configure a <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle for the local site.
374 Use <a href="../api_reference/C/dbsite_set_config.html" class="olink">DB_SITE-&gt;set_config()</a> to indicate that this
375 is a legacy site by setting the
376 <code class="literal">DB_LEGACY</code> parameter.
377 </p>
378 </li>
379 <li>
380 <p>
381 Configure a <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle for <span class="emphasis"><em>every
382 other site</em></span> in the replication
383 group. Set the <code class="literal">DB_LEGACY</code>
384 parameter for each of these handles.
385 </p>
386 <p>
387 Please pay careful attention to this step. To
388 repeat: a <a href="../api_reference/C/db_site.html" class="olink">DB_SITE</a> handle MUST be configured
389 for EVERY site in the replication group.
390 </p>
391 </li>
392 <li>
393 <p>
394 Start replication. The site is upgraded at this
395 point.
396 </p>
397 </li>
398 </ol>
399 </div>
400 <p>
401 Once you have performed this procedure for each
402 production site, making sure to upgrade the master only
403 after every other site has been upgraded, you are done
404 upgrading your replicated application to use the
405 current group membership mechanism.
406 </p>
407 </li>
408 </ul>
409 </div>
410 <p>
411 On subsequent restarts of your replication code, you do not
412 need to specify the <code class="literal">DB_LEGACY</code> parameter, nor
413 do you need to identify all of the replication group members.
414 However, it is not an error if you do specify this information
415 on subsequent start ups.
416 </p>
417 </div>
418 </div>
419 <div class="navfooter">
420 <hr />
421 <table width="100%" summary="Navigation footer">
422 <tr>
423 <td width="40%" align="left"><a accesskey="p" href="rep_newsite.html">Prev</a> </td>
424 <td width="20%" align="center">
425 <a accesskey="u" href="rep.html">Up</a>
426 </td>
427 <td width="40%" align="right"> <a accesskey="n" href="rep_filename.html">Next</a></td>
428 </tr>
429 <tr>
430 <td width="40%" align="left" valign="top">Connecting to a new site </td>
431 <td width="20%" align="center">
432 <a accesskey="h" href="index.html">Home</a>
433 </td>
434 <td width="40%" align="right" valign="top"> Managing Replication Files</td>
435 </tr>
436 </table>
437 </div>
438 </body>
439 </html>