File: dbsql_replicate.html

package info (click to toggle)
db 5.1.29-9
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 150,348 kB
  • sloc: ansic: 400,169; java: 94,399; tcl: 70,967; sh: 37,399; cs: 30,758; cpp: 21,132; perl: 14,227; xml: 9,854; makefile: 3,777; yacc: 1,003; awk: 942; sql: 801; erlang: 461; python: 216; php: 24; asm: 14
file content (243 lines) | stat: -rw-r--r-- 11,307 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Replicating Berkeley DB SQL Databases</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Getting Started with the Oracle Berkeley DB SQL APIs" />
    <link rel="up" href="admin.html" title="Chapter 4. Administrating Berkeley DB SQL Databases" />
    <link rel="prev" href="datamigration.html" title="Data Migration" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Replicating Berkeley DB SQL Databases</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="datamigration.html">Prev</a> </td>
          <th width="60%" align="center">Chapter 4. Administrating Berkeley DB SQL Databases</th>
          <td width="20%" align="right"> </td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="dbsql_replicate"></a>Replicating Berkeley DB SQL Databases</h2>
          </div>
        </div>
      </div>
      <div class="toc">
        <dl>
          <dt>
            <span class="sect2">
              <a href="dbsql_replicate.html#prep_rep">Preparing to use Replication with the Berkeley DB SQL API</a>
            </span>
          </dt>
          <dt>
            <span class="sect2">
              <a href="dbsql_replicate.html#use_rep">Using Replication with the Berkeley DB SQL API</a>
            </span>
          </dt>
        </dl>
      </div>
      <p>
                It is possible to replicate a Berkeley DB SQL database
                using the <a href="../api_reference/C/db_replicate.html" class="olink">db_replicate</a> utility. This section outlines the
                configuration steps required to enable replication, and
                provides an example of how to use the utility with a
                Berkeley DB SQL database.
            </p>
      <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
        <h3 class="title">Note</h3>
        <p>
                    The following section assumes that you are familiar
                    with Berkeley DB replication concepts. If not, you
                    should read the <a href="../programmer_reference/rep_replicate.html" class="olink">Running Replication using the db_replicate Utility</a>
                    section in the <em class="citetitle">Berkeley DB Programmer's Reference Guide</em>.
                </p>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="prep_rep"></a>Preparing to use Replication with the Berkeley DB SQL API</h3>
            </div>
          </div>
        </div>
        <p>
                    In order to use replication with a Berkeley DB SQL
                    application, you must do a few things prior to
                    creating a database.
                </p>
        <div class="orderedlist">
          <ol type="1">
            <li>
              <p>
                            Add the following lines to the
                            <code class="filename">DB_CONFIG</code> file:
                        </p>
              <pre class="programlisting">set_open_flags db_init_rep
add_data_dir ../ 
set_open_flags db_thread
set_open_flags db_register</pre>
              <p>
                            This causes the Berkeley DB SQL engine to
                            create a database that is compatible with
                            replication.
                        </p>
              <p>
                            See 
                            <a class="xref" href="using_dbconfig.html" title="The DB_CONFIG File">The DB_CONFIG File</a>
                            for more information about that file.
                        </p>
            </li>
            <li>
              <p>
                            Tell Berkeley DB how to startup the local
                            (current) site. Do this by adding a line to
                            the <code class="filename">DB_CONFIG</code> file of the form:
                        </p>
              <pre class="programlisting">repmgr_set_local_site &lt;address&gt; &lt;port&gt;</pre>
              <p>
                            where &lt;address&gt; is the URL for the local
                            machine and &lt;port&gt; is the port used on
                            this machine for replication communications.
                        </p>
              <p>
                            For more information, on configuring the local
                            site, see the <a href="../api_reference/C/repmgrlocal_site.html" class="olink">DB_ENV-&gt;repmgr_set_local_site()</a> method.
                        </p>
            </li>
            <li>
              <p>
                            Tell Berkeley DB about the other machines that
                            are participating in your replication group. Do
                            this by adding a line to the
                            <code class="filename">DB_CONFIG</code> file of the
                            form:
                        </p>
              <pre class="programlisting">repmgr_add_remote_site &lt;address&gt; &lt;port&gt;</pre>
              <p>
                          for each machine participating in your
                          replication group, other than the local machine.
                          Here, &lt;address&gt; is the URL for the remote
                          machine that you are identifying, and 
                          &lt;port&gt; is the port used on
                          that machine for replication communications.
                        </p>
              <p>
                            For more information, see the
                            <a href="../api_reference/C/repmgrremote_site.html" class="olink">DB_ENV-&gt;repmgr_add_remote_site()</a> method.
                        </p>
            </li>
          </ol>
        </div>
      </div>
      <div class="sect2" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h3 class="title"><a id="use_rep"></a>Using Replication with the Berkeley DB SQL API</h3>
            </div>
          </div>
        </div>
        <p>
                    Once you have performed the configuration steps
                    described in the previous section, you can start using
                    (and populating) your Berkeley DB SQL database as normal.
                </p>
        <p>
                    When you are ready to start replicating your Berkeley
                    DB SQL database, do the following:
                </p>
        <div class="orderedlist">
          <ol type="1">
            <li>
              <p>
                            Each site in the replication group needs to
                            have a starting point. The best way to create
                            that is to use a backup of the database that
                            will be replicated. Install a copy of the
                            backup at each of the sites in the replication
                            group. For detailed instructions on creating a backup,
                            see <a class="xref" href="admin.html#backup" title="Backing Up Berkeley DB SQL Databases">Backing Up Berkeley DB SQL Databases</a>.
                        </p>
            </li>
            <li>
              <p>
                            Create or update the
                            <code class="filename">DB_CONFIG</code> file at each
                            site in the replication group as discussed in
                            the previous section. Make sure that each site
                            has the correct settings for 
                             <a href="../api_reference/C/repmgrlocal_site.html" class="olink">DB_ENV-&gt;repmgr_set_local_site()</a> and
                             <a href="../api_reference/C/repmgrremote_site.html" class="olink">DB_ENV-&gt;repmgr_add_remote_site()</a>.
                        </p>
            </li>
            <li>
              <p>
                            On the site that you want to start as the
                            master of the replication group, run the
                            <a href="../api_reference/C/db_replicate.html" class="olink">db_replicate</a> utility in the following way:
                        </p>
              <pre class="programlisting">db_replicate -M -h &lt;journal-path&gt;</pre>
              <p>
                            where &lt;journal-path&gt; is the path to the
                            journal directory of the database that you want
                            to replicate.
                        </p>
            </li>
            <li>
              <p>
                            For each of the other sites in the group, run
                            the <code class="literal">db_replicate</code> utility
                            in the following way:
                        </p>
              <pre class="programlisting">db_replicate -h &lt;journal-path&gt;</pre>
              <p>
                            where &lt;journal-path&gt; is the path to the
                            journal directory of the database that you want
                            to replicate.
                        </p>
            </li>
            <li>
              <p>
                            Verify that replication has started
                            successfully. You can do this by issuing an
                            update operation on the site you selected as
                            the master, and then running a query
                            on a remote site to verify that the updated
                            contents are visible on the remote site.
                        </p>
            </li>
          </ol>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="datamigration.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="admin.html">Up</a>
          </td>
          <td width="40%" align="right"> </td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Data Migration </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> </td>
        </tr>
      </table>
    </div>
  </body>
</html>