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