]> git.sur5r.net Git - openldap/blob - doc/guide/admin/replication.sdf
Cleanup formatting. Reorganization preamble information for sharing
[openldap] / doc / guide / admin / replication.sdf
1 # Copyright 1999, The OpenLDAP Foundation, All Rights Reserved.
2 # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
3 H1: Replication with slurpd
4
5 In certain configurations, a single slapd instance may be
6 insufficient to handle the number of clients requiring
7 directory service via LDAP. It may become necessary to
8 run more than one slapd instance.  Many sites,
9 for instance, there are multiple slapd servers, one
10 master and one or slaves.  DNS can be setup such that
11 a lookup of ldap.openldap.org returns the IP addresses
12 of these servers, distributing the load among them. This
13 master/slave arrangement provides a simple and effective
14 way to increase capacity, availability and reliability.
15
16 Slurpd provides the capability for a master slapd to
17 propagate changes to slave slapd instances,
18 implementing the master/slave replication scheme
19 described above. Slurpd runs on the same host as the
20 master slapd instance.
21
22
23
24 H2: Overview
25
26 Slurpd provides replication services "in band". That is, it
27 uses the LDAP protocol to update a slave database from
28 the master. Perhaps the easiest way to illustrate this is
29 with an example. In this example, we trace the propagation
30 of an LDAP modify operation from its initiation by the LDAP
31 client to its distribution to the slave slapd instance.
32
33
34 {{B: Sample replication scenario:}}
35
36 * Step 1: An LDAP client starts up and connects to a slave
37 slapd. 
38
39 * Step 2: The LDAP client submits an LDAP modify
40 . operation to the slave slapd.
41
42 * Step 3: The slave slapd returns a referral to the LDAP
43 . client, which causes the client to send the modify
44 . operation to the master slapd. 
45
46 * Step 4: The master slapd performs the modify operation,
47 . writes out the change to its replication log file and returns
48 . a success code to the client. 
49
50 * Step 5: The slurpd process notices that a new entry has
51 . been appended to the replication log file, reads the
52 . replication log entry, and sends the change to the slave
53 . slapd via LDAP. 
54
55 * Step 6: The slave slapd performs the modify operation and
56 . returns a success code to the slurpd process. 
57
58 Note: if the LDAP client happened to connect to the
59 master slapd to begin with, Step 3 is omitted, but the rest
60 of the scenario remains the same.
61
62
63
64 H2: Replication Logs
65
66 When slapd is configured to generate a replication logfile,
67 it writes out a file in a format which is a variant of the LDIF
68 format. The replication log gives the replication site(s), a
69 timestamp, the DN of the entry being modified, and a series
70 of lines which specify the changes to make. In the
71 example below, "Barbara Jensen" has replaced a line of
72 her multiLineDescription. The change is to be propagated
73 to the slapd instance running on slave.openldap.org
74 The lastModifiedBy and lastModified Time attributes are
75 also propagated to the slave slapd.
76
77 E: replica: slave.openldap.org:389
78 E: time: 809618633
79 E: dn: cn=Barbara Jensen, ou=People, o=OpenLDAP Project,c=US
80 E: changetype: modify
81 E: delete: multiLineDescription
82 E: multiLineDescription: I enjoy sailing in my spare time
83 E: -
84 E: add: multiLineDescription
85 E: multiLineDescription: A dreamer...
86 E: -
87 E: delete: lastModifiedBy
88 E: -
89 E: add: lastModifiedBy
90 E: lastModifiedBy: cn=Barbara Jensen, ou=People, o=OpenLDAP Project, c=US
91 E: -
92 E: delete: lastModifiedTime
93 E: -
94 E: add: lastModifiedTime
95 E: lastModifiedTime: 950825073308Z
96 E: -
97
98 The modifications to {{EX: lastModifiedBy}} and {{EX: lastModifiedTime}}
99 were initiated by the master {{I: slapd}}.
100
101
102
103 H2: Command-Line Options
104
105 Slurpd supports the following command-line options.
106
107 E: -d <level> | ?
108
109 This option sets the slurpd debug level to {{EX: <level>}}. When
110 level is a `?' character, the various debugging levels are
111 printed and slapd exits, regardless of any other options
112 you give it. Current debugging levels (a subset of slapd's
113 debugging levels) are
114
115
116 E:          4 heavy trace debugging
117 E:         64 configuration file processing
118 E:      65535 enable all debugging
119
120 Debugging levels are additive. That is, if you want heavy
121 trace debugging and want to watch the config file being
122 processed, you would set level to the sum of those two
123 levels (in this case, 68).
124
125 E: -f <filename>
126
127 This option specifies an alternate slapd configuration file.
128 Slurpd does not have its own configuration file. Instead, all
129 configuration information is read from the slapd
130 configuration file.
131
132 E: -r <filename>
133
134 This option specifies an alternate slapd replication log file.
135 Under normal circumstances, slurpd reads the name of
136 the slapd replication log file from the slapd configuration
137 file. However, you can override this with the -r flag, to
138 cause slurpd to process a different replication log file. See
139 section 10.5, Advanced slurpd Operation, for a discussion
140 of how you might use this option.
141
142 E: -o
143
144 Operate in "one-shot" mode. Under normal
145 circumstances, when slurpd finishes processing a
146 replication log, it remains active and periodically checks to
147 see if new entries have been added to the replication log.
148 In one-shot mode, by comparison, slurpd processes a
149 replication log and exits immediately. If the -o option is
150 given, the replication log file must be explicitly specified
151 with the -r option
152
153 E: -t <directory>
154
155 Specify an alternate directory for slurpd's temporary
156 copies of replication logs. The default location is /usr/tmp.
157
158 E: -k <filename>
159
160 When slurpd uses kerberos to authenticate to slave slapd
161 instances, it needs to have an appropriate srvtab file for
162 the remote slapd. This option allows you to specify an
163 alternate filename containing kerberos keys for the remote
164 slapd. The default filename is /etc/srvtab. You can also
165 specify the srvtab file to use in the slapd configuration
166 file's replica option. See the documentation on the srvtab
167 directive in section 5.2.2, General Backend Options. A
168 more complete discussion of using kerberos with slapd
169 and slurpd may be found in Appendix D.
170
171
172
173 H2: Configuring slurpd and a slave slapd instance
174
175 To bring up a replica slapd instance, you must configure
176 the master and slave slapd instances for replication, then
177 shut down the master slapd so you can copy the
178 database. Finally, you bring up the master slapd instance,
179 the slave slapd instance, and the slurpd instance. These
180 steps are detailed in the following sections. You can set
181 up as many slave slapd instances as you wish.
182
183
184 H3: Set up the master slapd
185
186 Follow the procedures in Section 4, Building and Installing
187 slapd. Be sure that the slapd instance is working properly
188 before proceeding. Be sure to do the following in the
189 master slapd configuration file.
190
191 ^ Add a replica directive for each replica. The binddn=
192 . parameter should match the updatedn option in the
193 . corresponding slave slapd configuration file, and should
194 . name an entry with write permission to the slave database
195 . (e.g., an entry listed as rootdn, or allowed access via
196 . access directives in the slave slapd configuration file).
197
198 + Add a replogfile directive, which tells slapd where to log
199 . changes. This file will be read by slurpd.
200
201
202
203 H3: Set up the slave slapd
204
205 Install the slapd software on the host which is to be the
206 slave slapd server. The configuration of the slave server
207 should be identical to that of the master, with the following
208 exceptions:
209
210 ^ Do not include a replica directive. While it is possible to
211 . create "chains" of replicas, in most cases this is
212 . inappropriate.
213
214 + Do not include a replogfile directive.
215
216 + Do include an updatedn line. The DN given should
217 . match the DN given in the {{EX: binddn=}} parameter of the
218 . corresponding {{EX: replica=}} directive in the master slapd
219 . config file.
220
221 + Make sure the DN given in the {{EX: updatedn}} directive has
222 . permission to write the database (e.g., it is listed as rootdn
223 . or is allowed access by one or more access directives).
224
225
226
227 H3: Shut down the master slapd
228
229 In order to ensure that the slave starts with an exact copy
230 of the master's data, you must shut down the master
231 slapd. Do this by sending the master slapd process an
232 interrupt signal with {{EX: kill -TERM <pid>}}, where {{EX: <pid>}} is the
233 process-id of the master slapd process.
234
235 If you like, you may restart the master slapd in read-only
236 mode while you are replicating the database. During this
237 time, the master slapd will return an "unwilling to perform"
238 error to clients that attempt to modify data.
239
240
241
242 H3: Copy the master slapd's database to the slave
243
244 Copy the master's database(s) to the slave. For an
245 LDBM-based database, you must copy all index files as
246 well as the "NEXTID" file. Index files will have a different
247 suffix depending on the underlying database package
248 used. The current possibilities are
249
250 * {{EX: dbb}} Berkeley DB B-tree backend
251 * {{EX: dbh}} Berkeley DB hash backend
252 * {{EX: gdbm}} GNU DBM backend
253 * {{EX: pag}} UNIX NBDM backend
254 * {{EX: dir}} UNIX NBDM backend
255
256 You should copy all files with such a suffix that are located
257 in the index directory specified in your slapd config file.
258
259
260
261 H3: Configure the master slapd for replication
262
263 To configure slapd to generate a replication logfile, you
264 add a "{{EX: replica}}" configuration option to the master slapd's
265 config file. For example, if we wish to propagate changes
266 to the slapd instance running on host
267 slave.openldap.org:
268
269 E: replica host=slave.openldap.org:389
270 E:      binddn="cn=Replicator, o=OpenLDAP Project, c=US"
271 E:      bindmethod=simple credentials=secret
272
273 In this example, changes will be sent to port 389 (the
274 standard LDAP port) on host truelies. The slurpd process
275 will bind to the slave slapd as 
276 "cn=Replicator, o=OpenLDAP Project, c=US"
277 using simple authentication with password "secret".
278 Note that the entry given by the binddn= directive must
279 exist in the slave slapd's database (or be the rootdn
280 specified in the slapd config file) in order for the bind
281 operation to succeed.
282
283
284
285 H3: Restart the master slapd and start the slave slapd
286
287 Restart the master slapd process. To check that it is
288 generating replication logs, perform a modification of any
289 entry in the database, and check that data has been
290 written to the log file.
291
292
293
294 H3: Start slurpd
295
296 Start the slurpd process. Slurpd should immediately send
297 the test modification you made to the slave slapd. Watch
298 the slave slapd's logfile to be sure that the modification
299 was sent.
300
301 {{EX: slurpd -f <masterslapdconfigfile>}}
302
303
304
305 H2: Advanced slurpd Operation
306
307 H3: Replication errors
308
309 When slurpd propagates a change to a slave slapd and
310 receives an error return code, it writes the reason for the
311 error and the replication record to a reject file. The reject
312 file is located in the same directory with the per-replica
313 replication logfile, and has the same name, but with the
314 string ".rej" appended. For example, for a replica running
315 on host slave.openldap.org, port 389, the reject file, if it
316 exists, will be named
317
318 E: /usr/tmp/replog.slave.openldap.org:389.
319
320 A sample rejection log entry follows:
321
322 E: ERROR: No such attribute
323 E: replica: slave.openldap.org:389
324 E: time: 809618633
325 E: dn: cn=Barbara Jensen, ou=People, o=OpenLDAP Project, c=US
326 E: changetype: modify
327 E: delete: multiLineDescription
328 E: multiLineDescription: I enjoy sailing in my spare time
329 E: -
330 E: add: multiLineDescription
331 E: multiLineDescription: A dreamer...
332 E: -
333 E: delete: lastModifiedBy
334 E: -
335 E: add: lastModifiedBy
336 E: lastModifiedBy: cn=Barbara Jensen, ou=People, o=OpenLDAP Project, c=US
337 E: -
338 E: delete: lastModifiedTime
339 E: -
340 E: add: lastModifiedTime
341 E: lastModifiedTime: 950825073308Z
342 E: -
343
344 Note that this is precisely the same format as the original
345 replication log entry, but with an ERROR line prepended to
346 the entry.
347
348
349
350 H3: {{I:Slurpd}}'s one-shot mode and reject files
351
352 It is possible to use slurpd to process a rejection log with
353 its "one-shot mode." In normal operation, slurpd watches
354 for more replication records to be appended to the
355 replication log file. In one-shot mode, by contrast, slurpd
356 processes a single log file and exits. Slurpd ignores
357 ERROR lines at the beginning of replication log entries, so
358 it's not necessary to edit them out before feeding it the
359 rejection log.
360
361 To use one-shot mode, specify the name of the rejection
362 log on the command line as the argument to the -r flag,
363 and specify one-shot mode with the -o flag. For example,
364 to process the rejection log file
365 /usr/tmp/replog.slave.openldap.org:389 and exit, use the
366 command
367
368 E: slurpd -r /usr/tmp/replog.slave.openldap.org:389 -o
369
370
371 H2: Replication from a slapd directory server to an X.500 DSA
372
373 In mixed environments where both X.500 DSAs and slapd
374 are used, it may be desirable to replicate changes from a
375 slapd directory server to an X.500 DSA. This section
376 discusses issues involved with this method of replication,
377 and describes the currently-available facilities.
378
379 To propagate changes from a slapd directory server to an
380 X.500 DSA, slurpd runs on the master slapd host, and
381 sends changes to an ldapd which acts as a gateway to
382 the X.500 DSA:
383
384 !import "replication.gif"; align="center"; title="Replication from slapd to an X.500 DSA"
385 FT: Figure 6: Replication from slapd to an X.500 DSA
386
387 Note that the X.500 DSA must be a read-only copy. Since
388 the replication is one-way, updates from DAP clients
389 connecting to the X.500 DSA simply cannot be handled.
390
391 A problem arises where attribute names differ between the
392 slapd directory server and the X.500 DSA. At present,
393 slapd and slurpd do not support selective replication of
394 attributes, nor do they support translation of attribute
395 names and values. For example, slurpd will attempt to
396 update the "modifiersName" and "modifyTimeStamp"
397 attributes on the slave it connects to. However, the X.500
398 DSA may expect these attributes to be named
399 "lastModifiedBy" and "lastModifiedTime".
400
401 A solution to this attribute naming problem is to have the
402 ldapd read oidtables that map "modifiersName" to the
403 objectID (OID) for the "lastModifiedBy" attribute and
404 "modifyTimeStamp" to the OID for the "lastModifiedTime"
405 attribute. Since attribute names are carried as OIDs over
406 DAP, this should perform the appropriate translation of
407 attribute names.
408
409