]> 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 listed as
174 {{EX:rootdn}}, or allowed access via {{EX:access}} directives in
175 the slave slapd configuration file).
176
177 + Add a {{EX:replogfile}} directive, which tells slapd where to log
178 changes. This file will be read by slurpd.
179
180
181 H3: Set up the slave {{slapd}}
182
183 Install the slapd software on the host which is to be the slave
184 slapd server. The configuration of the slave server should be
185 identical to that of the master, with the following exceptions:
186
187 ^ Do not include a {{EX:replica}} directive. While it is possible
188 to create "chains" of replicas, in most cases this is inappropriate.
189
190 + Do not include a {{EX:replogfile}} directive.
191
192 + Do include an {{EX:updatedn}} line. The DN given should match the
193 DN given in the {{EX:binddn=}} parameter of the corresponding
194 {{EX:replica=}} directive in the master slapd config file.
195
196 + Make sure the DN given in the {{EX:updatedn}} directive has
197 permission to write the database (e.g., it is listed as {{EX:rootdn}}
198 or is allowed {{EX:access}} by one or more access directives).
199
200 + Use the {{EX:updateref}} directive to define the URL the slave
201 should return if an update request is received.
202
203
204 H3: Shut down the master server
205
206 In order to ensure that the slave starts with an exact copy of the
207 master's data, you must shut down the master slapd. Do this by
208 sending the master slapd process an interrupt signal with
209 {{EX:kill -INT <pid>}}, where {{EX:<pid>}} is the process-id of the master
210 slapd process.
211
212 If you like, you may restart the master slapd in read-only mode
213 while you are replicating the database. During this time, the master
214 slapd will return an "unwilling to perform" error to clients that
215 attempt to modify data.
216
217
218 H3: Copy the master slapd's database to the slave
219
220 Copy the master's database(s) to the slave. For an {{TERM:BDB}} and
221 {{TERM:LDBM}} databases, you must copy all database files located
222 in the database {{EX:directory}} specified in {{slapd.conf}}(5).
223 In general, you should copy each file found in the database {{EX:
224 directory}} unless you know it is not used by {{slapd}}(8).
225
226 Note: This copy process assumes homogeneous servers with identically
227 configured OpenLDAP installations. Alternatively, you may use
228 {{slapcat}} to output the master's database in LDIF format and use
229 the LDIF with {{slapadd}} to populate the slave. Using LDIF avoids
230 any potential incompatibilities due to differing server architectures
231 or software configurations.  See the {{SECT:Database Creation and
232 Maintenance Tools}} chapter for details on these tools.
233
234
235 H3: Configure the master slapd for replication
236
237 To configure slapd to generate a replication logfile, you add a
238 "{{EX: replica}}" configuration option to the master slapd's config
239 file. For example, if we wish to propagate changes to the slapd
240 instance running on host {{EX:slave.example.com}}:
241
242 >       replica host=slave.example.com:389
243 >               binddn="cn=Replicator,dc=example,dc=com"
244 >               bindmethod=simple credentials=secret
245
246 In this example, changes will be sent to port 389 (the standard
247 LDAP port) on host slave.example.com. The slurpd process will bind
248 to the slave slapd as "{{EX:cn=Replicator,dc=example,dc=com}}" using
249 simple authentication with password "{{EX:secret}}".  Note that the
250 DN given by the {{EX:binddn=}} directive must exist in the slave
251 slapd's database (or be the rootdn specified in the slapd config
252 file) in order for the bind operation to succeed.  The DN should
253 also be listed as the {{EX:updatedn}} for the database in the slave's
254 slapd.conf(5).
255
256 Note: The use of strong authentication and transport security is
257 highly recommended.
258
259
260 H3: Restart the master slapd and start the slave slapd
261
262 Restart the master slapd process. To check that it is
263 generating replication logs, perform a modification of any
264 entry in the database, and check that data has been
265 written to the log file.
266
267
268 H3: Start slurpd
269
270 Start the slurpd process. Slurpd should immediately send
271 the test modification you made to the slave slapd. Watch
272 the slave slapd's logfile to be sure that the modification
273 was sent.
274
275 >       slurpd -f <masterslapdconfigfile>
276
277
278
279 H2: Advanced slurpd Operation
280
281 H3: Replication errors
282
283 When slurpd propagates a change to a slave slapd and receives an
284 error return code, it writes the reason for the error and the
285 replication record to a reject file. The reject file is located in
286 the same directory as the per-replica replication logfile, and has
287 the same name, but with the string "{{F:.rej}}" appended. For
288 example, for a replica running on host {{EX:slave.example.com}},
289 port 389, the reject file, if it exists, will be named
290
291 >       /usr/local/var/openldap/replog.slave.example.com:389.rej
292
293 A sample rejection log entry follows:
294
295 >       ERROR: No such attribute
296 >       replica: slave.example.com:389
297 >       time: 809618633
298 >       dn: uid=bjensen,dc=example,dc=com
299 >       changetype: modify
300 >       replace: description
301 >       description: A dreamer...
302 >       -
303 >       replace: modifiersName
304 >       modifiersName: uid=bjensen,dc=example,dc=com
305 >       -
306 >       replace: modifyTimestamp
307 >       modifyTimestamp: 20000805073308Z
308 >       -
309
310 Note that this is precisely the same format as the original replication
311 log entry, but with an {{EX:ERROR}} line prepended to the entry.
312
313
314
315 H3: One-shot mode and reject files
316
317 It is possible to use slurpd to process a rejection log with its
318 "one-shot mode." In normal operation, slurpd watches for more
319 replication records to be appended to the replication log file. In
320 one-shot mode, by contrast, slurpd processes a single log file and
321 exits. Slurpd ignores {{EX:ERROR}} lines at the beginning of
322 replication log entries, so it's not necessary to edit them out
323 before feeding it the rejection log.
324
325 To use one-shot mode, specify the name of the rejection log on the
326 command line as the argument to the -r flag, and specify one-shot
327 mode with the -o flag. For example, to process the rejection log
328 file {{F:/usr/local/var/openldap/replog.slave.example.com:389}} and
329 exit, use the command
330
331 >       slurpd -r /usr/tmp/replog.slave.example.com:389 -o
332
333 !if 0
334
335 H2: Replication to an X.500 DSA
336
337 In mixed environments where both {{TERM:X.500}} DSAs and slapd are
338 used, it may be desirable to replicate changes from a slapd directory
339 server to an X.500 {{TERM:DSA}}. This section discusses issues
340 involved with this method of replication, and describes the
341 currently-available facilities.
342
343 To propagate changes from a slapd directory server to an X.500 DSA,
344 slurpd runs on the master slapd host, and sends changes to an ldapd
345 which acts as a gateway to the X.500 DSA:
346
347 !import "replication.gif"; align="center"; \
348         title="Replication from slapd to an X.500 DSA"
349 FT: Figure 10.1: Replication from slapd to an X.500 DSA
350
351 Note that the X.500 DSA must be a read-only copy. Since the replication
352 is one-way, updates from {{TERM:DAP}} clients connecting to the
353 X.500 DSA simply cannot be handled.
354
355 A problem arises where attribute names differ between the slapd
356 directory server and the X.500 DSA. At present, slapd and slurpd
357 do not support selective replication of attributes, nor do they
358 support translation of attribute names and values. For example,
359 slurpd will attempt to update the {{EX:modifiersName}} and
360 {{EX:modifyTimeStamp}} attributes on the slave it connects to.
361 However, the X.500 DSA may expect these attributes to be named
362 {{EX:lastModifiedBy}} and {{EX:lastModifiedTime}}.
363
364 A solution to this attribute naming problem is to have the LDAP/DAP
365 gateway to map {{EX:modifiersName}} to the Object Identifier
366 ({{TERM:OID}}) for the {{EX:lastModifiedBy}} attribute and
367 {{EX:modifyTimeStamp}} to the OID for the {{EX:lastModifiedTime}}
368 attribute. Since attribute names are carried as OIDs over DAP, this
369 should perform the appropriate translation of attribute names.
370
371 !endif