]> git.sur5r.net Git - openldap/blob - doc/guide/admin/replication.sdf
ed32a9431aa5af1ef40a7019b3c704acf012ec01
[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}}(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 H2: Replication Logs
61
62 When slapd is configured to generate a replication logfile,
63 it writes out a file containing {{TERM:LDIF}} change records.
64 The replication log gives the replication site(s), a
65 timestamp, the DN of the entry being modified, and a series
66 of lines which specify the changes to make. In the
67 example below, Barbara ({{EX:uid=bjensen}}) has replaced the {{EX:description}}
68 value.  The change is to be propagated
69 to the slapd instance running on {{EX:slave.example.net}}
70 Changes to various operational attributes, such as {{EX:modifiersName}}
71 and {{EX:modifyTimestamp}}, are included in the change record and
72 will be propagated to the slave slapd.
73
74 >       replica: slave.example.com:389
75 >       time: 809618633
76 >       dn: uid=bjensen,dc=example,dc=com
77 >       changetype: modify
78 >       replace: multiLineDescription
79 >       description: A dreamer...
80 >       -
81 >       replace: modifiersName
82 >       modifiersName: uid=bjensen,dc=example,dc=com
83 >       -
84 >       replace: modifyTimestamp
85 >       modifyTimestamp: 20000805073308Z
86 >       -
87
88 The modifications to {{EX:modifiersName}} and {{EX:modifyTimestamp}}
89 operational attributes were added by the master {{slapd}}.
90
91
92
93 H2: Command-Line Options
94
95 This section details commonly used {{slurpd}}(8) command-line options.
96
97 >       -d <level> | ?
98
99 This option sets the slurpd debug level to {{EX: <level>}}. When
100 level is a `?' character, the various debugging levels are
101 printed and slapd exits, regardless of any other options
102 you give it. Current debugging levels (a subset of slapd's
103 debugging levels) are
104
105 !block table; colaligns="RL"; align=Center; \
106         title="Table 10.1: Debugging Levels"
107 Level   Description
108 4       heavy trace debugging
109 64      configuration file processing
110 65535   enable all debugging
111 !endblock
112
113 Debugging levels are additive. That is, if you want heavy
114 trace debugging and want to watch the config file being
115 processed, you would set level to the sum of those two
116 levels (in this case, 68).
117
118 >       -f <filename>
119
120 This option specifies an alternate slapd configuration file.
121 Slurpd does not have its own configuration file. Instead, all
122 configuration information is read from the slapd
123 configuration file.
124
125 >       -r <filename>
126
127 This option specifies an alternate slapd replication log file.
128 Under normal circumstances, slurpd reads the name of
129 the slapd replication log file from the slapd configuration
130 file. However, you can override this with the -r flag, to
131 cause slurpd to process a different replication log file. See
132 the {{SECT:Advanced slurpd Operation}} section for a discussion
133 of how you might use this option.
134
135 >       -o
136
137 Operate in "one-shot" mode. Under normal
138 circumstances, when slurpd finishes processing a
139 replication log, it remains active and periodically checks to
140 see if new entries have been added to the replication log.
141 In one-shot mode, by comparison, slurpd processes a
142 replication log and exits immediately. If the -o option is
143 given, the replication log file must be explicitly specified
144 with the -r option.  See the {{SECT:One-shot mode and reject files}}
145 section for  a discussion of this mode.
146
147 >       -t <directory>
148
149 Specify an alternate directory for slurpd's temporary
150 copies of replication logs. The default location is /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
156 the master and slave slapd instances for replication, then
157 shut down the master slapd so you can copy the
158 database. Finally, you bring up the master slapd instance,
159 the slave slapd instance, and the slurpd instance. These
160 steps are detailed in the following sections. You can set
161 up as many slave slapd instances as you wish.
162
163
164 H3: Set up the master {{slapd}}
165
166 The following section assumes you have a properly
167 working {{slapd}}(8) instance. To configure your working
168 {{slapd}}(8) server as a replication master, you need
169 to make the following changes to your {{slapd.conf}}(5).
170
171 ^ Add a {{EX:replica}} directive for each replica. The {{EX:binddn=}}
172 parameter should match the {{EX:updatedn}} option in the
173 corresponding slave slapd configuration file, and should
174 name an entry with write permission to the slave database
175 (e.g., an entry listed as {{EX:rootdn}}, or allowed access via
176 {{EX:access}} directives in the slave slapd configuration file).
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
183 H3: Set up the slave {{slapd}}
184
185 Install the slapd software on the host which is to be the
186 slave slapd server. The configuration of the slave server
187 should be identical to that of the master, with the following
188 exceptions:
189
190 ^ Do not include a {{EX:replica}} directive. While it is
191 possible to create "chains" of replicas, in most cases this is
192 inappropriate.
193
194 + Do not include a {{EX:replogfile}} directive.
195
196 + Do include an {{EX:updatedn}} line. The DN given should
197 match the DN given in the {{EX:binddn=}} parameter of the
198 corresponding {{EX:replica=}} directive in the master slapd
199 config file.
200
201 + Make sure the DN given in the {{EX:updatedn}} directive has
202 permission to write the database (e.g., it is listed as {{EX:rootdn}}
203 or is allowed {{EX:access}} by one or more access directives).
204
205 + Use the {{EX:updateref}} directive to define the URL the
206 slave should return if an update request is received.
207
208
209 H3: Shut down the master {{slapd}}
210
211 In order to ensure that the slave starts with an exact copy
212 of the master's data, you must shut down the master
213 slapd. Do this by sending the master slapd process an
214 interrupt signal with {{EX:kill -INT <pid>}}, where
215 {{EX:<pid>}} is the process-id of the master slapd process.
216
217 If you like, you may restart the master slapd in read-only
218 mode while you are replicating the database. During this
219 time, the master slapd will return an "unwilling to perform"
220 error to clients that attempt to modify data.
221
222
223 H3: Copy the master slapd's database to the slave
224
225 Copy the master's database(s) to the slave. For an
226 {{TERM:LDBM}}-based database, you must copy all database
227 files located in the database {{EX:directory}} specified in
228 {{slapd.conf}}(5).  Database files will have a different
229 suffix depending on the underlying database package used.
230 The current possibilities are
231
232 !block table; align=Center; \
233         title="Table 10.2: Database File Suffixes"
234 Suffix          Database
235 {{EX:dbb}}      Berkeley DB B-tree backend
236 {{EX:dbh}}      Berkeley DB hash backend
237 {{EX:gdbm}}     GNU DBM backend
238 !endblock
239
240 In general, you should copy each file found in the database
241 {{EX: directory}} unless you know it is not used by {{slapd}}(8).
242
243 Note: The copy process assumes homogeneous servers with
244 identically configured OpenLDAP installations.
245
246
247 H3: Configure the master slapd for replication
248
249 To configure slapd to generate a replication logfile, you
250 add a "{{EX: replica}}" configuration option to the master slapd's
251 config file. For example, if we wish to propagate changes
252 to the slapd instance running on host
253 {{EX:slave.example.com}}:
254
255 >       replica host=slave.example.com:389
256 >               binddn="cn=Replicator,dc=example,dc=com"
257 >               bindmethod=simple credentials=secret
258
259 In this example, changes will be sent to port 389 (the
260 standard LDAP port) on host slave.example.com. The slurpd
261 process will bind to the slave slapd as 
262 "{{EX:cn=Replicator,dc=example,dc=com}}" using simple authentication
263 with password "{{EX:secret}}".  Note that the DN given by the {{EX:binddn=}}
264 directive must exist in the slave slapd's database (or be
265 the rootdn specified in the slapd config file) in order for the
266 bind operation to succeed.  The DN should also be listed as
267 the {{EX:updatedn}} for the database in the slave's slapd.conf(5).
268
269 Note: The use of strong authentication and transport security
270 is highly recommended.
271
272
273 H3: Restart the master slapd and start the slave slapd
274
275 Restart the master slapd process. To check that it is
276 generating replication logs, perform a modification of any
277 entry in the database, and check that data has been
278 written to the log file.
279
280
281 H3: Start slurpd
282
283 Start the slurpd process. Slurpd should immediately send
284 the test modification you made to the slave slapd. Watch
285 the slave slapd's logfile to be sure that the modification
286 was sent.
287
288 >       slurpd -f <masterslapdconfigfile>
289
290
291
292 H2: Advanced slurpd Operation
293
294 H3: Replication errors
295
296 When slurpd propagates a change to a slave slapd and
297 receives an error return code, it writes the reason for the
298 error and the replication record to a reject file. The reject
299 file is located in the same directory as the per-replica
300 replication logfile, and has the same name, but with the
301 string "{{F:.rej}}" appended. For example, for a replica running
302 on host {{EX:slave.example.com}}, port 389, the reject file, if it
303 exists, will be named
304
305 >       /usr/local/var/openldap/replog.slave.example.com:389.rej
306
307 A sample rejection log entry follows:
308
309 >       ERROR: No such attribute
310 >       replica: slave.example.com:389
311 >       time: 809618633
312 >       dn: uid=bjensen,dc=example,dc=com
313 >       changetype: modify
314 >       replace: description
315 >       description: A dreamer...
316 >       -
317 >       replace: modifiersName
318 >       modifiersName: uid=bjensen,dc=example,dc=com
319 >       -
320 >       replace: modifyTimestamp
321 >       modifyTimestamp: 20000805073308Z
322 >       -
323
324 Note that this is precisely the same format as the original
325 replication log entry, but with an {{EX:ERROR}} line prepended to
326 the entry.
327
328
329
330 H3: One-shot mode and reject files
331
332 It is possible to use slurpd to process a rejection log with
333 its "one-shot mode." In normal operation, slurpd watches
334 for more replication records to be appended to the
335 replication log file. In one-shot mode, by contrast, slurpd
336 processes a single log file and exits. Slurpd ignores
337 {{EX:ERROR}} lines at the beginning of replication log entries, so
338 it's not necessary to edit them out before feeding it the
339 rejection log.
340
341 To use one-shot mode, specify the name of the rejection
342 log on the command line as the argument to the -r flag,
343 and specify one-shot mode with the -o flag. For example,
344 to process the rejection log file
345 {{F:/usr/local/var/openldap/replog.slave.example.com:389}}
346 and exit, use the command
347
348 >       slurpd -r /usr/tmp/replog.slave.example.com:389 -o
349
350 !if 0
351
352 H2: Replication to an X.500 DSA
353
354 In mixed environments where both {{TERM:X.500}} DSAs and slapd
355 are used, it may be desirable to replicate changes from a
356 slapd directory server to an X.500 {{TERM:DSA}}. This section
357 discusses issues involved with this method of replication,
358 and describes the currently-available facilities.
359
360 To propagate changes from a slapd directory server to an
361 X.500 DSA, slurpd runs on the master slapd host, and
362 sends changes to an ldapd which acts as a gateway to
363 the X.500 DSA:
364
365 !import "replication.gif"; align="center"; \
366         title="Replication from slapd to an X.500 DSA"
367 FT: Figure 10.1: Replication from slapd to an X.500 DSA
368
369 Note that the X.500 DSA must be a read-only copy. Since
370 the replication is one-way, updates from {{TERM:DAP}} clients
371 connecting to the X.500 DSA simply cannot be handled.
372
373 A problem arises where attribute names differ between the
374 slapd directory server and the X.500 DSA. At present,
375 slapd and slurpd do not support selective replication of
376 attributes, nor do they support translation of attribute
377 names and values. For example, slurpd will attempt to
378 update the {{EX:modifiersName}} and {{EX:modifyTimeStamp}}
379 attributes on the slave it connects to. However, the X.500
380 DSA may expect these attributes to be named
381 {{EX:lastModifiedBy}} and {{EX:lastModifiedTime}}.
382
383 A solution to this attribute naming problem is to have the
384 LDAP/DAP gateway to map {{EX:modifiersName}} to the Object
385 Identifier ({{TERM:OID}}) for the {{EX:lastModifiedBy}}
386 attribute and {{EX:modifyTimeStamp}} to the OID for the
387 {{EX:lastModifiedTime}} attribute. Since attribute names
388 are carried as OIDs over DAP, this should perform the
389 appropriate translation of attribute names.
390
391 !endif