]> git.sur5r.net Git - openldap/blob - doc/guide/admin/replication.sdf
Sync with HEAD
[openldap] / doc / guide / admin / replication.sdf
1 # $OpenLDAP$
2 # Copyright 1999-2003, The OpenLDAP Foundation, All Rights Reserved.
3 # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
4 H1: Replication with slurpd
5
6 In certain configurations, a single {{slapd}}(8) instance may be
7 insufficient to handle the number of clients requiring
8 directory service via LDAP. It may become necessary to
9 run more than one slapd instance.  At many sites,
10 for instance, there are multiple slapd servers: one
11 master and one or more slaves.  {{TERM:DNS}} can be setup such that
12 a lookup of {{EX:ldap.example.com}} returns the {{TERM:IP}} addresses
13 of these servers, distributing the load among them (or
14 just the slaves). This master/slave arrangement provides
15 a simple and effective way to increase capacity, availability
16 and reliability.
17
18 {{slurpd}}(8) provides the capability for a master slapd to
19 propagate changes to slave slapd instances,
20 implementing the master/slave replication scheme
21 described above.  slurpd runs on the same host as the
22 master slapd instance.
23
24
25
26 H2: Overview
27
28 {{slurpd}}(8) provides replication services "in band". That is, it
29 uses the LDAP protocol to update a slave database from
30 the master. Perhaps the easiest way to illustrate this is
31 with an example. In this example, we trace the propagation
32 of an LDAP modify operation from its initiation by the LDAP
33 client to its distribution to the slave slapd instance.
34
35
36 {{B: Sample replication scenario:}}
37
38 ^ The LDAP client submits an LDAP modify operation to
39 the slave slapd.
40
41 + The slave slapd returns a referral to the LDAP
42 client referring the client to the master slapd.
43
44 + The LDAP client submits the LDAP modify operation to
45 the master slapd.
46
47 + The master slapd performs the modify operation,
48 writes out the change to its replication log file and returns
49 a success code to the client. 
50
51 + The slurpd process notices that a new entry has
52 been appended to the replication log file, reads the
53 replication log entry, and sends the change to the slave
54 slapd via LDAP. 
55
56 + The slave slapd performs the modify operation and
57 returns a success code to the slurpd process. 
58
59
60 Note: {{ldapmodify}}(1) and other tools distributed as part of
61 OpenLDAP Software do not support automatic referral chasing.
62
63
64
65 H2: Replication Logs
66
67 When slapd is configured to generate a replication logfile, it
68 writes out a file containing {{TERM:LDIF}} change records.  The
69 replication log gives the replication site(s), a timestamp, the DN
70 of the entry being modified, and a series of lines which specify
71 the changes to make. In the example below, Barbara ({{EX:uid=bjensen}})
72 has replaced the {{EX:description}} value.  The change is to be
73 propagated to the slapd instance running on {{EX:slave.example.net}}
74 Changes to various operational attributes, such as {{EX:modifiersName}}
75 and {{EX:modifyTimestamp}}, are included in the change record and
76 will be propagated to the slave slapd.
77
78 >       replica: slave.example.com:389
79 >       time: 809618633
80 >       dn: uid=bjensen,dc=example,dc=com
81 >       changetype: modify
82 >       replace: multiLineDescription
83 >       description: A dreamer...
84 >       -
85 >       replace: modifiersName
86 >       modifiersName: uid=bjensen,dc=example,dc=com
87 >       -
88 >       replace: modifyTimestamp
89 >       modifyTimestamp: 20000805073308Z
90 >       -
91
92 The modifications to {{EX:modifiersName}} and {{EX:modifyTimestamp}}
93 operational attributes were added by the master {{slapd}}.
94
95
96
97 H2: Command-Line Options
98
99 This section details commonly used {{slurpd}}(8) command-line options.
100
101 >       -d <level> | ?
102
103 This option sets the slurpd debug level to {{EX: <level>}}. When
104 level is a `?' character, the various debugging levels are printed
105 and slurpd exits, regardless of any other options you give it.
106 Current debugging levels (a subset of slapd's debugging levels) are
107
108 !block table; colaligns="RL"; align=Center; \
109         title="Table 13.1: Debugging Levels"
110 Level   Description
111 4       heavy trace debugging
112 64      configuration file processing
113 65535   enable all debugging
114 !endblock
115
116 Debugging levels are additive. That is, if you want heavy trace
117 debugging and want to watch the config file being processed, you
118 would set level to the sum of those two levels (in this case, 68).
119
120 >       -f <filename>
121
122 This option specifies an alternate slapd configuration file.  Slurpd
123 does not have its own configuration file. Instead, all configuration
124 information is read from the slapd configuration file.
125
126 >       -r <filename>
127
128 This option specifies an alternate slapd replication log file.
129 Under normal circumstances, slurpd reads the name of the slapd
130 replication log file from the slapd configuration file. However,
131 you can override this with the -r flag, to cause slurpd to process
132 a different replication log file. See the {{SECT:Advanced slurpd
133 Operation}} section for a discussion of how you might use this
134 option.
135
136 >       -o
137
138 Operate in "one-shot" mode. Under normal circumstances, when slurpd
139 finishes processing a replication log, it remains active and
140 periodically checks to see if new entries have been added to the
141 replication log.  In one-shot mode, by comparison, slurpd processes
142 a replication log and exits immediately. If the -o option is given,
143 the replication log file must be explicitly specified with the -r
144 option.  See the {{SECT:One-shot mode and reject files}} section
145 for  a discussion of this mode.
146
147 >       -t <directory>
148
149 Specify an alternate directory for slurpd's temporary copies of
150 replication logs. The default location is {{F:/usr/tmp}}.
151
152
153 H2: Configuring slurpd and a slave slapd instance
154
155 To bring up a replica slapd instance, you must configure the master
156 and slave slapd instances for replication, then shut down the master
157 slapd so you can copy the database. Finally, you bring up the master
158 slapd instance, the slave slapd instance, and the slurpd instance.
159 These steps are detailed in the following sections. You can set up
160 as many slave slapd instances as you wish.
161
162
163 H3: Set up the master {{slapd}}
164
165 The following section assumes you have a properly working {{slapd}}(8)
166 instance. To configure your working {{slapd}}(8) server as a
167 replication master, you need to make the following changes to your
168 {{slapd.conf}}(5).
169
170 ^ Add a {{EX:replica}} directive for each replica. The {{EX:binddn=}}
171 parameter should match the {{EX:updatedn}} option in the corresponding
172 slave slapd configuration file, and should name an entry with write
173 permission to the slave database (e.g., an entry allowed access via
174 {{EX:access}} directives in the slave slapd configuration file).
175 This DN generally {{should not}} be the same as the master's
176 {{EX:rootdn}}.
177
178 + Add a {{EX:replogfile}} directive, which tells slapd where to log
179 changes. This file will be read by slurpd.
180
181
182 H3: Set up the slave {{slapd}}
183
184 Install the slapd software on the host which is to be the slave
185 slapd server. The configuration of the slave server should be
186 identical to that of the master, with the following exceptions:
187
188 ^ Do not include a {{EX:replica}} directive. While it is possible
189 to create "chains" of replicas, in most cases this is inappropriate.
190
191 + Do not include a {{EX:replogfile}} directive.
192
193 + Do include an {{EX:updatedn}} line. The DN given should match the
194 DN given in the {{EX:binddn=}} parameter of the corresponding
195 {{EX:replica=}} directive in the master slapd config file.  The
196 {{EX:updatedn}} generally {{should not}} be the same as the
197 {{EX:rootdn}} of the master database.
198
199 + Make sure the DN given in the {{EX:updatedn}} directive has
200 permission to write the database (e.g., it is is allowed {{EX:access}}
201 by one or more access directives).
202
203 + Use the {{EX:updateref}} directive to define the URL the slave
204 should return if an update request is received.
205
206
207 H3: Shut down the master server
208
209 In order to ensure that the slave starts with an exact copy of the
210 master's data, you must shut down the master slapd. Do this by
211 sending the master slapd process an interrupt signal with
212 {{EX:kill -INT <pid>}}, where {{EX:<pid>}} is the process-id of the master
213 slapd process.
214
215 If you like, you may restart the master slapd in read-only mode
216 while you are replicating the database. During this time, the master
217 slapd will return an "unwilling to perform" error to clients that
218 attempt to modify data.
219
220
221 H3: Copy the master slapd's database to the slave
222
223 Copy the master's database(s) to the slave. For an {{TERM:BDB}} and
224 {{TERM:LDBM}} databases, you must copy all database files located
225 in the database {{EX:directory}} specified in {{slapd.conf}}(5).
226 In general, you should copy each file found in the database {{EX:
227 directory}} unless you know it is not used by {{slapd}}(8).
228
229 Note: This copy process assumes homogeneous servers with identically
230 configured OpenLDAP installations. Alternatively, you may use
231 {{slapcat}} to output the master's database in LDIF format and use
232 the LDIF with {{slapadd}} to populate the slave. Using LDIF avoids
233 any potential incompatibilities due to differing server architectures
234 or software configurations.  See the {{SECT:Database Creation and
235 Maintenance Tools}} chapter for details on these tools.
236
237
238 H3: Configure the master slapd for replication
239
240 To configure slapd to generate a replication logfile, you add a
241 "{{EX: replica}}" configuration option to the master slapd's config
242 file. For example, if we wish to propagate changes to the slapd
243 instance running on host {{EX:slave.example.com}}:
244
245 >       replica uri=ldap://slave.example.com:389
246 >               binddn="cn=Replicator,dc=example,dc=com"
247 >               bindmethod=simple credentials=secret
248
249 In this example, changes will be sent to port 389 (the standard
250 LDAP port) on host slave.example.com. The slurpd process will bind
251 to the slave slapd as "{{EX:cn=Replicator,dc=example,dc=com}}" using
252 simple authentication with password "{{EX:secret}}".
253
254 If we wish to perform the same replication using ldaps on port 636:  
255
256 >       replica uri=ldaps://slave.example.com:636
257 >               binddn="cn=Replicator,dc=example,dc=com"
258 >               bindmethod=simple credentials=secret
259
260 The host option is deprecated in favor of uri, but the following 
261 replica configuration is still supported:
262
263 >       replica host=slave.example.com:389
264 >               binddn="cn=Replicator,dc=example,dc=com"
265 >               bindmethod=simple credentials=secret
266
267 Note that the DN given by the {{EX:binddn=}} directive must exist
268 in the slave slapd's database (or be the rootdn specified in the
269 slapd config file) in order for the bind operation to succeed.  The
270 DN should also be listed as the {{EX:updatedn}} for the database
271 in the slave's slapd.conf(5).  It is generally recommended that
272 this DN be different than the {{EX:rootdn}} of the master database.
273
274 Note: The use of strong authentication and transport security is
275 highly recommended.
276
277
278 H3: Restart the master slapd and start the slave slapd
279
280 Restart the master slapd process. To check that it is
281 generating replication logs, perform a modification of any
282 entry in the database, and check that data has been
283 written to the log file.
284
285
286 H3: Start slurpd
287
288 Start the slurpd process. Slurpd should immediately send
289 the test modification you made to the slave slapd. Watch
290 the slave slapd's logfile to be sure that the modification
291 was sent.
292
293 >       slurpd -f <masterslapdconfigfile>
294
295
296
297 H2: Advanced slurpd Operation
298
299 H3: Replication errors
300
301 When slurpd propagates a change to a slave slapd and receives an
302 error return code, it writes the reason for the error and the
303 replication record to a reject file. The reject file is located in
304 the same directory as the per-replica replication logfile, and has
305 the same name, but with the string "{{F:.rej}}" appended. For
306 example, for a replica running on host {{EX:slave.example.com}},
307 port 389, the reject file, if it exists, will be named
308
309 >       /usr/local/var/openldap/replog.slave.example.com:389.rej
310
311 A sample rejection log entry follows:
312
313 >       ERROR: No such attribute
314 >       replica: slave.example.com:389
315 >       time: 809618633
316 >       dn: uid=bjensen,dc=example,dc=com
317 >       changetype: modify
318 >       replace: description
319 >       description: A dreamer...
320 >       -
321 >       replace: modifiersName
322 >       modifiersName: uid=bjensen,dc=example,dc=com
323 >       -
324 >       replace: modifyTimestamp
325 >       modifyTimestamp: 20000805073308Z
326 >       -
327
328 Note that this is precisely the same format as the original replication
329 log entry, but with an {{EX:ERROR}} line prepended to the entry.
330
331
332
333 H3: One-shot mode and reject files
334
335 It is possible to use slurpd to process a rejection log with its
336 "one-shot mode." In normal operation, slurpd watches for more
337 replication records to be appended to the replication log file. In
338 one-shot mode, by contrast, slurpd processes a single log file and
339 exits. Slurpd ignores {{EX:ERROR}} lines at the beginning of
340 replication log entries, so it's not necessary to edit them out
341 before feeding it the rejection log.
342
343 To use one-shot mode, specify the name of the rejection log on the
344 command line as the argument to the -r flag, and specify one-shot
345 mode with the -o flag. For example, to process the rejection log
346 file {{F:/usr/local/var/openldap/replog.slave.example.com:389}} and
347 exit, use the command
348
349 >       slurpd -r /usr/tmp/replog.slave.example.com:389 -o
350