1999-10-01 00:57:45 +08:00
|
|
|
# $OpenLDAP$
|
2006-01-04 07:11:52 +08:00
|
|
|
# Copyright 1999-2006 The OpenLDAP Foundation, All Rights Reserved.
|
1999-04-24 07:41:45 +08:00
|
|
|
# COPYING RESTRICTIONS APPLY, see COPYRIGHT.
|
1999-04-24 07:00:44 +08:00
|
|
|
H1: Replication with slurpd
|
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
In certain configurations, a single {{slapd}}(8) instance may be
|
1999-04-24 07:00:44 +08:00
|
|
|
insufficient to handle the number of clients requiring
|
|
|
|
directory service via LDAP. It may become necessary to
|
2000-09-05 06:51:48 +08:00
|
|
|
run more than one slapd instance. At many sites,
|
|
|
|
for instance, there are multiple slapd servers: one
|
2000-08-08 12:19:21 +08:00
|
|
|
master and one or more slaves. {{TERM:DNS}} can be setup such that
|
2000-08-08 12:21:33 +08:00
|
|
|
a lookup of {{EX:ldap.example.com}} returns the {{TERM:IP}} addresses
|
2000-08-08 12:02:24 +08:00
|
|
|
of these servers, distributing the load among them (or
|
|
|
|
just the slaves). This master/slave arrangement provides
|
|
|
|
a simple and effective way to increase capacity, availability
|
|
|
|
and reliability.
|
|
|
|
|
|
|
|
{{slurpd}}(8) provides the capability for a master slapd to
|
1999-04-24 07:00:44 +08:00
|
|
|
propagate changes to slave slapd instances,
|
|
|
|
implementing the master/slave replication scheme
|
2000-08-08 12:21:33 +08:00
|
|
|
described above. slurpd runs on the same host as the
|
1999-04-24 07:00:44 +08:00
|
|
|
master slapd instance.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
H2: Overview
|
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
{{slurpd}}(8) provides replication services "in band". That is, it
|
1999-04-24 07:00:44 +08:00
|
|
|
uses the LDAP protocol to update a slave database from
|
|
|
|
the master. Perhaps the easiest way to illustrate this is
|
|
|
|
with an example. In this example, we trace the propagation
|
|
|
|
of an LDAP modify operation from its initiation by the LDAP
|
|
|
|
client to its distribution to the slave slapd instance.
|
|
|
|
|
|
|
|
|
|
|
|
{{B: Sample replication scenario:}}
|
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
^ The LDAP client submits an LDAP modify operation to
|
|
|
|
the slave slapd.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
+ The slave slapd returns a referral to the LDAP
|
|
|
|
client referring the client to the master slapd.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
+ The LDAP client submits the LDAP modify operation to
|
|
|
|
the master slapd.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
+ The master slapd performs the modify operation,
|
|
|
|
writes out the change to its replication log file and returns
|
|
|
|
a success code to the client.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
+ The slurpd process notices that a new entry has
|
|
|
|
been appended to the replication log file, reads the
|
|
|
|
replication log entry, and sends the change to the slave
|
|
|
|
slapd via LDAP.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
+ The slave slapd performs the modify operation and
|
|
|
|
returns a success code to the slurpd process.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
2005-03-20 02:37:16 +08:00
|
|
|
Note: {{ldapmodify}}(1) and other clients distributed as part of
|
|
|
|
OpenLDAP Software do not support automatic referral chasing
|
|
|
|
(for security reasons).
|
2002-10-28 05:45:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
1999-04-24 07:00:44 +08:00
|
|
|
H2: Replication Logs
|
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
When slapd is configured to generate a replication logfile, it
|
|
|
|
writes out a file containing {{TERM:LDIF}} change records. The
|
|
|
|
replication log gives the replication site(s), a timestamp, the DN
|
|
|
|
of the entry being modified, and a series of lines which specify
|
|
|
|
the changes to make. In the example below, Barbara ({{EX:uid=bjensen}})
|
|
|
|
has replaced the {{EX:description}} value. The change is to be
|
|
|
|
propagated to the slapd instance running on {{EX:slave.example.net}}
|
2000-08-08 12:02:24 +08:00
|
|
|
Changes to various operational attributes, such as {{EX:modifiersName}}
|
|
|
|
and {{EX:modifyTimestamp}}, are included in the change record and
|
|
|
|
will be propagated to the slave slapd.
|
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> replica: slave.example.com:389
|
|
|
|
> time: 809618633
|
2000-10-24 03:00:05 +08:00
|
|
|
> dn: uid=bjensen,dc=example,dc=com
|
2000-08-10 13:23:38 +08:00
|
|
|
> changetype: modify
|
|
|
|
> replace: multiLineDescription
|
|
|
|
> description: A dreamer...
|
|
|
|
> -
|
|
|
|
> replace: modifiersName
|
2000-10-24 03:00:05 +08:00
|
|
|
> modifiersName: uid=bjensen,dc=example,dc=com
|
2000-08-10 13:23:38 +08:00
|
|
|
> -
|
|
|
|
> replace: modifyTimestamp
|
|
|
|
> modifyTimestamp: 20000805073308Z
|
|
|
|
> -
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-08 12:02:24 +08:00
|
|
|
The modifications to {{EX:modifiersName}} and {{EX:modifyTimestamp}}
|
|
|
|
operational attributes were added by the master {{slapd}}.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
H2: Command-Line Options
|
|
|
|
|
2000-08-11 07:57:21 +08:00
|
|
|
This section details commonly used {{slurpd}}(8) command-line options.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> -d <level> | ?
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
This option sets the slurpd debug level to {{EX: <level>}}. When
|
2002-10-28 05:45:17 +08:00
|
|
|
level is a `?' character, the various debugging levels are printed
|
|
|
|
and slurpd exits, regardless of any other options you give it.
|
|
|
|
Current debugging levels (a subset of slapd's debugging levels) are
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-12 14:35:08 +08:00
|
|
|
!block table; colaligns="RL"; align=Center; \
|
2002-08-28 12:05:07 +08:00
|
|
|
title="Table 13.1: Debugging Levels"
|
2000-08-12 14:35:08 +08:00
|
|
|
Level Description
|
|
|
|
4 heavy trace debugging
|
|
|
|
64 configuration file processing
|
|
|
|
65535 enable all debugging
|
|
|
|
!endblock
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
Debugging levels are additive. That is, if you want heavy trace
|
|
|
|
debugging and want to watch the config file being processed, you
|
|
|
|
would set level to the sum of those two levels (in this case, 68).
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> -f <filename>
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
This option specifies an alternate slapd configuration file. Slurpd
|
|
|
|
does not have its own configuration file. Instead, all configuration
|
|
|
|
information is read from the slapd configuration file.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> -r <filename>
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
This option specifies an alternate slapd replication log file.
|
2002-10-28 05:45:17 +08:00
|
|
|
Under normal circumstances, slurpd reads the name of the slapd
|
|
|
|
replication log file from the slapd configuration file. However,
|
|
|
|
you can override this with the -r flag, to cause slurpd to process
|
|
|
|
a different replication log file. See the {{SECT:Advanced slurpd
|
|
|
|
Operation}} section for a discussion of how you might use this
|
|
|
|
option.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> -o
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
Operate in "one-shot" mode. Under normal circumstances, when slurpd
|
|
|
|
finishes processing a replication log, it remains active and
|
|
|
|
periodically checks to see if new entries have been added to the
|
|
|
|
replication log. In one-shot mode, by comparison, slurpd processes
|
|
|
|
a replication log and exits immediately. If the -o option is given,
|
|
|
|
the replication log file must be explicitly specified with the -r
|
|
|
|
option. See the {{SECT:One-shot mode and reject files}} section
|
|
|
|
for a discussion of this mode.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> -t <directory>
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-06-17 13:56:55 +08:00
|
|
|
Specify an alternate directory for slurpd's temporary copies of
|
|
|
|
replication logs. The default location is {{F:/usr/tmp}}.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
H2: Configuring slurpd and a slave slapd instance
|
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
To bring up a replica slapd instance, you must configure the master
|
|
|
|
and slave slapd instances for replication, then shut down the master
|
|
|
|
slapd so you can copy the database. Finally, you bring up the master
|
|
|
|
slapd instance, the slave slapd instance, and the slurpd instance.
|
|
|
|
These steps are detailed in the following sections. You can set up
|
|
|
|
as many slave slapd instances as you wish.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
2000-08-11 07:57:21 +08:00
|
|
|
H3: Set up the master {{slapd}}
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
The following section assumes you have a properly working {{slapd}}(8)
|
|
|
|
instance. To configure your working {{slapd}}(8) server as a
|
|
|
|
replication master, you need to make the following changes to your
|
|
|
|
{{slapd.conf}}(5).
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-11 07:57:21 +08:00
|
|
|
^ Add a {{EX:replica}} directive for each replica. The {{EX:binddn=}}
|
2002-10-28 05:45:17 +08:00
|
|
|
parameter should match the {{EX:updatedn}} option in the corresponding
|
|
|
|
slave slapd configuration file, and should name an entry with write
|
2003-12-18 08:06:55 +08:00
|
|
|
permission to the slave database (e.g., an entry allowed access via
|
|
|
|
{{EX:access}} directives in the slave slapd configuration file).
|
2004-02-26 01:20:49 +08:00
|
|
|
This DN generally {{should not}} be the same as the master's
|
|
|
|
{{EX:rootdn}}.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-11 07:57:21 +08:00
|
|
|
+ Add a {{EX:replogfile}} directive, which tells slapd where to log
|
2000-08-08 12:02:24 +08:00
|
|
|
changes. This file will be read by slurpd.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
2000-08-11 07:57:21 +08:00
|
|
|
H3: Set up the slave {{slapd}}
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
Install the slapd software on the host which is to be the slave
|
|
|
|
slapd server. The configuration of the slave server should be
|
|
|
|
identical to that of the master, with the following exceptions:
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
^ Do not include a {{EX:replica}} directive. While it is possible
|
|
|
|
to create "chains" of replicas, in most cases this is inappropriate.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-11 07:57:21 +08:00
|
|
|
+ Do not include a {{EX:replogfile}} directive.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
+ Do include an {{EX:updatedn}} line. The DN given should match the
|
|
|
|
DN given in the {{EX:binddn=}} parameter of the corresponding
|
2003-12-18 08:06:55 +08:00
|
|
|
{{EX:replica=}} directive in the master slapd config file. The
|
2004-02-26 01:20:49 +08:00
|
|
|
{{EX:updatedn}} generally {{should not}} be the same as the
|
|
|
|
{{EX:rootdn}} of the master database.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-11 07:57:21 +08:00
|
|
|
+ Make sure the DN given in the {{EX:updatedn}} directive has
|
2003-12-18 08:06:55 +08:00
|
|
|
permission to write the database (e.g., it is is allowed {{EX:access}}
|
|
|
|
by one or more access directives).
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
+ Use the {{EX:updateref}} directive to define the URL the slave
|
|
|
|
should return if an update request is received.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
2003-02-06 04:38:58 +08:00
|
|
|
H3: Shut down the master server
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
In order to ensure that the slave starts with an exact copy of the
|
|
|
|
master's data, you must shut down the master slapd. Do this by
|
2003-02-06 04:38:58 +08:00
|
|
|
sending the master slapd process an interrupt signal with
|
|
|
|
{{EX:kill -INT <pid>}}, where {{EX:<pid>}} is the process-id of the master
|
2002-10-28 05:45:17 +08:00
|
|
|
slapd process.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
If you like, you may restart the master slapd in read-only mode
|
|
|
|
while you are replicating the database. During this time, the master
|
|
|
|
slapd will return an "unwilling to perform" error to clients that
|
|
|
|
attempt to modify data.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
H3: Copy the master slapd's database to the slave
|
|
|
|
|
2006-02-17 17:24:57 +08:00
|
|
|
Copy the master's database(s) to the slave. For {{TERM:BDB}} and
|
|
|
|
{{TERM:HDB}} databases, you must copy all database files located
|
2002-06-17 13:56:55 +08:00
|
|
|
in the database {{EX:directory}} specified in {{slapd.conf}}(5).
|
|
|
|
In general, you should copy each file found in the database {{EX:
|
|
|
|
directory}} unless you know it is not used by {{slapd}}(8).
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
Note: This copy process assumes homogeneous servers with identically
|
|
|
|
configured OpenLDAP installations. Alternatively, you may use
|
|
|
|
{{slapcat}} to output the master's database in LDIF format and use
|
|
|
|
the LDIF with {{slapadd}} to populate the slave. Using LDIF avoids
|
|
|
|
any potential incompatibilities due to differing server architectures
|
|
|
|
or software configurations. See the {{SECT:Database Creation and
|
|
|
|
Maintenance Tools}} chapter for details on these tools.
|
2000-08-11 07:57:21 +08:00
|
|
|
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
H3: Configure the master slapd for replication
|
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
To configure slapd to generate a replication logfile, you add a
|
|
|
|
"{{EX: replica}}" configuration option to the master slapd's config
|
|
|
|
file. For example, if we wish to propagate changes to the slapd
|
|
|
|
instance running on host {{EX:slave.example.com}}:
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2003-09-27 15:14:29 +08:00
|
|
|
> replica uri=ldap://slave.example.com:389
|
2000-08-10 13:23:38 +08:00
|
|
|
> binddn="cn=Replicator,dc=example,dc=com"
|
|
|
|
> bindmethod=simple credentials=secret
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
In this example, changes will be sent to port 389 (the standard
|
|
|
|
LDAP port) on host slave.example.com. The slurpd process will bind
|
|
|
|
to the slave slapd as "{{EX:cn=Replicator,dc=example,dc=com}}" using
|
2003-09-27 15:14:29 +08:00
|
|
|
simple authentication with password "{{EX:secret}}".
|
|
|
|
|
|
|
|
If we wish to perform the same replication using ldaps on port 636:
|
|
|
|
|
|
|
|
> replica uri=ldaps://slave.example.com:636
|
|
|
|
> binddn="cn=Replicator,dc=example,dc=com"
|
|
|
|
> bindmethod=simple credentials=secret
|
|
|
|
|
|
|
|
The host option is deprecated in favor of uri, but the following
|
|
|
|
replica configuration is still supported:
|
|
|
|
|
|
|
|
> replica host=slave.example.com:389
|
|
|
|
> binddn="cn=Replicator,dc=example,dc=com"
|
|
|
|
> bindmethod=simple credentials=secret
|
|
|
|
|
2003-12-18 08:06:55 +08:00
|
|
|
Note that the DN given by the {{EX:binddn=}} directive must exist
|
|
|
|
in the slave slapd's database (or be the rootdn specified in the
|
|
|
|
slapd config file) in order for the bind operation to succeed. The
|
|
|
|
DN should also be listed as the {{EX:updatedn}} for the database
|
|
|
|
in the slave's slapd.conf(5). It is generally recommended that
|
|
|
|
this DN be different than the {{EX:rootdn}} of the master database.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
Note: The use of strong authentication and transport security is
|
|
|
|
highly recommended.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
H3: Restart the master slapd and start the slave slapd
|
|
|
|
|
|
|
|
Restart the master slapd process. To check that it is
|
|
|
|
generating replication logs, perform a modification of any
|
|
|
|
entry in the database, and check that data has been
|
|
|
|
written to the log file.
|
|
|
|
|
|
|
|
|
|
|
|
H3: Start slurpd
|
|
|
|
|
|
|
|
Start the slurpd process. Slurpd should immediately send
|
|
|
|
the test modification you made to the slave slapd. Watch
|
|
|
|
the slave slapd's logfile to be sure that the modification
|
|
|
|
was sent.
|
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> slurpd -f <masterslapdconfigfile>
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
H2: Advanced slurpd Operation
|
|
|
|
|
|
|
|
H3: Replication errors
|
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
When slurpd propagates a change to a slave slapd and receives an
|
|
|
|
error return code, it writes the reason for the error and the
|
|
|
|
replication record to a reject file. The reject file is located in
|
|
|
|
the same directory as the per-replica replication logfile, and has
|
|
|
|
the same name, but with the string "{{F:.rej}}" appended. For
|
|
|
|
example, for a replica running on host {{EX:slave.example.com}},
|
|
|
|
port 389, the reject file, if it exists, will be named
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-09-15 00:40:12 +08:00
|
|
|
> /usr/local/var/openldap/replog.slave.example.com:389.rej
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
A sample rejection log entry follows:
|
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> ERROR: No such attribute
|
|
|
|
> replica: slave.example.com:389
|
|
|
|
> time: 809618633
|
2000-10-24 03:00:05 +08:00
|
|
|
> dn: uid=bjensen,dc=example,dc=com
|
2000-08-10 13:23:38 +08:00
|
|
|
> changetype: modify
|
|
|
|
> replace: description
|
|
|
|
> description: A dreamer...
|
|
|
|
> -
|
|
|
|
> replace: modifiersName
|
2000-10-24 03:00:05 +08:00
|
|
|
> modifiersName: uid=bjensen,dc=example,dc=com
|
2000-08-10 13:23:38 +08:00
|
|
|
> -
|
|
|
|
> replace: modifyTimestamp
|
|
|
|
> modifyTimestamp: 20000805073308Z
|
|
|
|
> -
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
Note that this is precisely the same format as the original replication
|
|
|
|
log entry, but with an {{EX:ERROR}} line prepended to the entry.
|
1999-04-24 07:00:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-08-11 07:57:21 +08:00
|
|
|
H3: One-shot mode and reject files
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2002-10-28 05:45:17 +08:00
|
|
|
It is possible to use slurpd to process a rejection log with its
|
|
|
|
"one-shot mode." In normal operation, slurpd watches for more
|
|
|
|
replication records to be appended to the replication log file. In
|
|
|
|
one-shot mode, by contrast, slurpd processes a single log file and
|
|
|
|
exits. Slurpd ignores {{EX:ERROR}} lines at the beginning of
|
|
|
|
replication log entries, so it's not necessary to edit them out
|
|
|
|
before feeding it the rejection log.
|
|
|
|
|
|
|
|
To use one-shot mode, specify the name of the rejection log on the
|
|
|
|
command line as the argument to the -r flag, and specify one-shot
|
|
|
|
mode with the -o flag. For example, to process the rejection log
|
|
|
|
file {{F:/usr/local/var/openldap/replog.slave.example.com:389}} and
|
|
|
|
exit, use the command
|
1999-04-24 07:00:44 +08:00
|
|
|
|
2000-08-10 13:23:38 +08:00
|
|
|
> slurpd -r /usr/tmp/replog.slave.example.com:389 -o
|
1999-04-24 07:00:44 +08:00
|
|
|
|