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