📄 replication.sdf
字号:
# $OpenLDAP: pkg/openldap-guide/admin/replication.sdf,v 1.30.2.2 2007/01/02 21:43:43 kurt Exp $# Copyright 1999-2007 The OpenLDAP Foundation, All Rights Reserved.# COPYING RESTRICTIONS APPLY, see COPYRIGHT.H1: Replication with slurpdIn certain configurations, a single {{slapd}}(8) instance may beinsufficient to handle the number of clients requiringdirectory service via LDAP. It may become necessary torun more than one slapd instance. At many sites,for instance, there are multiple slapd servers: onemaster and one or more slaves. {{TERM:DNS}} can be setup such thata lookup of {{EX:ldap.example.com}} returns the {{TERM:IP}} addressesof these servers, distributing the load among them (orjust the slaves). This master/slave arrangement providesa simple and effective way to increase capacity, availabilityand reliability.{{slurpd}}(8) provides the capability for a master slapd topropagate changes to slave slapd instances,implementing the master/slave replication schemedescribed above. slurpd runs on the same host as themaster slapd instance.H2: Overview{{slurpd}}(8) provides replication services "in band". That is, ituses the LDAP protocol to update a slave database fromthe master. Perhaps the easiest way to illustrate this iswith an example. In this example, we trace the propagationof an LDAP modify operation from its initiation by the LDAPclient to its distribution to the slave slapd instance.{{B: Sample replication scenario:}}^ The LDAP client submits an LDAP modify operation tothe slave slapd.+ The slave slapd returns a referral to the LDAPclient referring the client to the master slapd.+ The LDAP client submits the LDAP modify operation tothe master slapd.+ The master slapd performs the modify operation,writes out the change to its replication log file and returnsa success code to the client. + The slurpd process notices that a new entry hasbeen appended to the replication log file, reads thereplication log entry, and sends the change to the slaveslapd via LDAP. + The slave slapd performs the modify operation andreturns a success code to the slurpd process. Note: {{ldapmodify}}(1) and other clients distributed as part ofOpenLDAP Software do not support automatic referral chasing(for security reasons).H2: Replication LogsWhen slapd is configured to generate a replication logfile, itwrites out a file containing {{TERM:LDIF}} change records. Thereplication log gives the replication site(s), a timestamp, the DNof the entry being modified, and a series of lines which specifythe changes to make. In the example below, Barbara ({{EX:uid=bjensen}})has replaced the {{EX:description}} value. The change is to bepropagated to the slapd instance running on {{EX:slave.example.net}}Changes to various operational attributes, such as {{EX:modifiersName}}and {{EX:modifyTimestamp}}, are included in the change record andwill be propagated to the slave slapd.> replica: slave.example.com:389> time: 809618633> dn: uid=bjensen,dc=example,dc=com> changetype: modify> replace: multiLineDescription> description: A dreamer...> -> replace: modifiersName> modifiersName: uid=bjensen,dc=example,dc=com> -> replace: modifyTimestamp> modifyTimestamp: 20000805073308Z> -The modifications to {{EX:modifiersName}} and {{EX:modifyTimestamp}}operational attributes were added by the master {{slapd}}.H2: Command-Line OptionsThis section details commonly used {{slurpd}}(8) command-line options.> -d <level> | ?This option sets the slurpd debug level to {{EX: <level>}}. Whenlevel is a `?' character, the various debugging levels are printedand slurpd exits, regardless of any other options you give it.Current debugging levels (a subset of slapd's debugging levels) are!block table; colaligns="RL"; align=Center; \ title="Table 13.1: Debugging Levels"Level Description4 heavy trace debugging64 configuration file processing65535 enable all debugging!endblockDebugging levels are additive. That is, if you want heavy tracedebugging and want to watch the config file being processed, youwould set level to the sum of those two levels (in this case, 68).> -f <filename>This option specifies an alternate slapd configuration file. Slurpddoes not have its own configuration file. Instead, all configurationinformation is read from the slapd configuration file.> -r <filename>This option specifies an alternate slapd replication log file.Under normal circumstances, slurpd reads the name of the slapdreplication log file from the slapd configuration file. However,you can override this with the -r flag, to cause slurpd to processa different replication log file. See the {{SECT:Advanced slurpdOperation}} section for a discussion of how you might use thisoption.> -oOperate in "one-shot" mode. Under normal circumstances, when slurpdfinishes processing a replication log, it remains active andperiodically checks to see if new entries have been added to thereplication log. In one-shot mode, by comparison, slurpd processesa replication log and exits immediately. If the -o option is given,the replication log file must be explicitly specified with the -roption. See the {{SECT:One-shot mode and reject files}} sectionfor a discussion of this mode.> -t <directory>Specify an alternate directory for slurpd's temporary copies ofreplication logs. The default location is {{F:/usr/tmp}}.H2: Configuring slurpd and a slave slapd instanceTo bring up a replica slapd instance, you must configure the masterand slave slapd instances for replication, then shut down the masterslapd so you can copy the database. Finally, you bring up the masterslapd instance, the slave slapd instance, and the slurpd instance.These steps are detailed in the following sections. You can set upas many slave slapd instances as you wish.H3: Set up the master {{slapd}}The following section assumes you have a properly working {{slapd}}(8)instance. To configure your working {{slapd}}(8) server as areplication master, you need to make the following changes to your{{slapd.conf}}(5).^ Add a {{EX:replica}} directive for each replica. The {{EX:binddn=}}parameter should match the {{EX:updatedn}} option in the correspondingslave slapd configuration file, and should name an entry with writepermission to the slave database (e.g., an entry allowed access via{{EX:access}} directives in the slave slapd configuration file).This DN generally {{should not}} be the same as the master's{{EX:rootdn}}.+ Add a {{EX:replogfile}} directive, which tells slapd where to logchanges. This file will be read by slurpd.H3: Set up the slave {{slapd}}Install the slapd software on the host which is to be the slaveslapd server. The configuration of the slave server should beidentical to that of the master, with the following exceptions:^ Do not include a {{EX:replica}} directive. While it is possibleto create "chains" of replicas, in most cases this is inappropriate.+ Do not include a {{EX:replogfile}} directive.+ Do include an {{EX:updatedn}} line. The DN given should match theDN given in the {{EX:binddn=}} parameter of the corresponding{{EX:replica=}} directive in the master slapd config file. The{{EX:updatedn}} generally {{should not}} be the same as the{{EX:rootdn}} of the master database.+ Make sure the DN given in the {{EX:updatedn}} directive haspermission to write the database (e.g., it is is allowed {{EX:access}}by one or more access directives).+ Use the {{EX:updateref}} directive to define the URL the slaveshould return if an update request is received.H3: Shut down the master serverIn order to ensure that the slave starts with an exact copy of themaster's data, you must shut down the master slapd. Do this bysending the master slapd process an interrupt signal with{{EX:kill -INT <pid>}}, where {{EX:<pid>}} is the process-id of the masterslapd process.If you like, you may restart the master slapd in read-only modewhile you are replicating the database. During this time, the masterslapd will return an "unwilling to perform" error to clients thatattempt to modify data.H3: Copy the master slapd's database to the slaveCopy the master's database(s) to the slave. For an {{TERM:BDB}} and{{TERM:LDBM}} databases, you must copy all database files locatedin 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).Note: This copy process assumes homogeneous servers with identicallyconfigured OpenLDAP installations. Alternatively, you may use{{slapcat}} to output the master's database in LDIF format and usethe LDIF with {{slapadd}} to populate the slave. Using LDIF avoidsany potential incompatibilities due to differing server architecturesor software configurations. See the {{SECT:Database Creation andMaintenance Tools}} chapter for details on these tools.H3: Configure the master slapd for replicationTo configure slapd to generate a replication logfile, you add a"{{EX: replica}}" configuration option to the master slapd's configfile. For example, if we wish to propagate changes to the slapdinstance running on host {{EX:slave.example.com}}:> replica uri=ldap://slave.example.com:389> binddn="cn=Replicator,dc=example,dc=com"> bindmethod=simple credentials=secretIn this example, changes will be sent to port 389 (the standardLDAP port) on host slave.example.com. The slurpd process will bindto the slave slapd as "{{EX:cn=Replicator,dc=example,dc=com}}" usingsimple 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=secretThe 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=secretNote that the DN given by the {{EX:binddn=}} directive must existin the slave slapd's database (or be the rootdn specified in theslapd config file) in order for the bind operation to succeed. TheDN should also be listed as the {{EX:updatedn}} for the databasein the slave's slapd.conf(5). It is generally recommended thatthis DN be different than the {{EX:rootdn}} of the master database.Note: The use of strong authentication and transport security ishighly recommended.H3: Restart the master slapd and start the slave slapdRestart the master slapd process. To check that it isgenerating replication logs, perform a modification of anyentry in the database, and check that data has beenwritten to the log file.H3: Start slurpdStart the slurpd process. Slurpd should immediately sendthe test modification you made to the slave slapd. Watchthe slave slapd's logfile to be sure that the modificationwas sent.> slurpd -f <masterslapdconfigfile>H2: Advanced slurpd OperationH3: Replication errorsWhen slurpd propagates a change to a slave slapd and receives anerror return code, it writes the reason for the error and thereplication record to a reject file. The reject file is located inthe same directory as the per-replica replication logfile, and hasthe same name, but with the string "{{F:.rej}}" appended. Forexample, for a replica running on host {{EX:slave.example.com}},port 389, the reject file, if it exists, will be named> /usr/local/var/openldap/replog.slave.example.com:389.rejA sample rejection log entry follows:> ERROR: No such attribute> replica: slave.example.com:389> time: 809618633> dn: uid=bjensen,dc=example,dc=com> changetype: modify> replace: description> description: A dreamer...> -> replace: modifiersName> modifiersName: uid=bjensen,dc=example,dc=com> -> replace: modifyTimestamp> modifyTimestamp: 20000805073308Z> -Note that this is precisely the same format as the original replicationlog entry, but with an {{EX:ERROR}} line prepended to the entry.H3: One-shot mode and reject filesIt is possible to use slurpd to process a rejection log with its"one-shot mode." In normal operation, slurpd watches for morereplication records to be appended to the replication log file. Inone-shot mode, by contrast, slurpd processes a single log file andexits. Slurpd ignores {{EX:ERROR}} lines at the beginning ofreplication log entries, so it's not necessary to edit them outbefore feeding it the rejection log.To use one-shot mode, specify the name of the rejection log on thecommand line as the argument to the -r flag, and specify one-shotmode with the -o flag. For example, to process the rejection logfile {{F:/usr/local/var/openldap/replog.slave.example.com:389}} andexit, use the command> slurpd -r /usr/tmp/replog.slave.example.com:389 -o
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -