]> git.sur5r.net Git - openldap/blob - doc/guide/admin/syncrepl.sdf
Formating
[openldap] / doc / guide / admin / syncrepl.sdf
1 # $OpenLDAP$
2 # Copyright 2003, The OpenLDAP Foundation, All Rights Reserved.
3 # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
4
5 H1: LDAP Sync Replication
6
7 The LDAP Sync replication engine is designed to function as an
8 improved alternative to {{slurpd}}(8).  While the replication with
9 {{slurpd}}(8) provides the replication capability for improved capacity,
10 availability, and reliability, it has some drawbacks:
11
12 ^ It is {{not stateful}}, hence lacks the resynchronization capability.
13 Because there is no representation of replica state in the replication
14 with {{slurpd}}(8), it is not possible to provide an efficient
15 mechanism to make the slave replica consistent to the master replica
16 once they become out of sync. For instance, if the slave database
17 content is damaged, the slave replica should be re-primed from the
18 master replica again. with a state-based replication, it would be
19 possible to recover the slave replica from a local backup. The slave
20 replica, then, will be synchronized by calculating and transmitting
21 the diffs between the slave replica and the master replica based
22 on their states. The LDAP Sync replication is {{stateful}}.
23
24 + It is {{history-based}}, not {{state-based}}. The replication with
25 {{slurpd}}(8) relies on the history information in the replication
26 log file generated by {{slapd}}(8). If a portion of the log file
27 that contains updates yet to be synchronized to the slave is truncated
28 or damaged, a full reload is required. The state-based replication,
29 on the other hand, would not rely on the separate history store.
30 In the LDAP Sync replication, every directory entry has its state
31 information in the {{EX:entryCSN}} operational attribute. The replica
32 contents are calculated based on the consumer cookie and the
33 {{EX:entryCSN}} of the directory entries.
34
35 + It is {{push-based}}, not {{pull-based}}. In the replication with
36 {{slurpd}}(8), it is the master who decides when to synchronize the
37 replica. The pull-based polling replication is not possible with
38 {{slurpd}}(8). For example, in order to make a daily directory backup
39 which is an exact image at a time, it is required to make the slave
40 replica read-only by stopping {{slurpd}}(8) during backup. After backup,
41 {{slurpd}}(8) can be run in an one-shot mode to resynchronize the slave
42 replica with the updates during the backup. In a pull-based, polling
43 replication, it is guaranteed to be read-only between the two polling
44 points. The LDAP Sync replication supports both {{push-based}}
45 and {{pull-based}} replication.
46
47 + It only supports the fractional replication and does not support
48 the sparse replication. The LDAP Sync replication supports both the
49 fractional and sparse replication. It is possible to use general
50 search specification to initiate a synchronization session only for
51 the interesting subset of the context.
52
53
54 H2: The LDAP Content Sychronization Operation
55
56 The LDAP Sync replication uses the LDAP Content Synchronization (or
57 LDAP Sync) protocol (refer to the Internet Draft titled {{The LDAP
58 Content Synchronization Operation}}) for replica synchronization.
59
60 The LDAP Sync operation is based on the replica state which is
61 transmitted between replicas as the synchronization cookies.  There
62 are two operating modes: {{refreshOnly}} and {{refreshAndPersist}}.
63 In both modes, a consumer {{slapd}}(8) connects to a provider
64 {{slapd}}(8) with a cookie value representing the state of the
65 consumer replica.  The non-persistent part of the synchronization
66 consists of two phases.
67
68 The first is the {{state-based}} phase. The entries updated after
69 the point in time the consumer cookie represents will be transmitted
70 to the consumer. Because the unit of synchronization is entry, all
71 the requested attributes will be transmitted even though only some
72 of them are changed. For the rest of the entries, the present
73 messages consisting only of the name and the synchronization control
74 will be sent to the consumer. After the consumer receives all the
75 updated and present entries, it can reliably make its replica
76 consistent to the provider replica. The consumer will add all the
77 newly added entries, replace the entries if updated entries are
78 existent, and delete entries in the local replica if they are neither
79 updated nor specified as present.
80
81 The second is the {{log-based}} phase. This phase is incorporated
82 to optimize the protocol with respect to the volume of the present
83 traffic. If the provider maintains a history store from which the
84 content to be synchronized can be reliably calculated, this log-base
85 phase follows the state-base phase. In this mode, the actual directory
86 update operations such as delete, modify, and add are transmitted.
87 There is no need to send present messages in this log-based phase.
88
89 If the protocol operates in the {{refreshOnly}} mode, the synchronization
90 will terminate. The provider will send a synchronization cookie
91 which reflects the new state to the consumer. The consumer will
92 present the new cookie at the next time it requests a synchronization.
93 If the protocol operates in the {{refreshAndPersist}} mode, the
94 synchronization operation remains persistent in the provider. Every
95 updates made to the provider replica will be transmitted to the
96 consumer. Cookies can be sent to the consumer at any time by using
97 the SyncInfo intermediate response and at the end of the synchronization
98 by using the SyncDone control attached to the SearchResultDone
99 message.
100
101 Entries are uniquely identified by the {{EX:entryUUID}} attribute
102 value in the LDAP Content Sync protocol. It can role as a reliable
103 entry identifier while DN of an entry can change by modrdn operations.
104 The {{EX:entryUUID}} is attached to each SearchResultEntry or
105 SearchResultReference as a part of the Sync State control.
106
107
108 H2: LDAP Sync Replication Details
109
110 The LDAP Sync replication uses both the {{refreshOnly}} and the
111 {{refreshAndPersist}} modes of synchronization.  If an LDAP Sync
112 replication is specified in a database definition, the {{slapd}}(8)
113 schedules an execution of the LDAP Sync replication engine. In the
114 {{refreshOnly}} mode, the engine will be rescheduled at the interval
115 time after a replication session ends. In the {{refreshAndPersist}}
116 mode, the engine will remain active to process the SearchResultEntry
117 messages from the provider.
118
119 The LDAP Sync replication uses only the state-based synchronization
120 phase.  Because {{slapd}}(8) does not currently implement history store
121 like changelog or tombstone, it depends only on the state-base
122 phase. A Null log-base phase follows the state-base phase.
123
124 As an optimization, no entries will be transmitted to a consumer
125 if there has been no update in the master replica after the last
126 synchronization with the consumer. Even present messages for the
127 unchanged entries are not transmitted. The consumer retains its
128 replica contents.
129
130 H3: entryCSN
131
132 The LDAP Sync replication implemented in {{slapd}}(8) stores state
133 information to ever entry in the {{EX:entryCSN}} attribute.
134 {{EX:entryCSN}} of an entry is the CSN or {{change sequence number}},
135 which is the refined timestamp, at which the entry was updated most
136 lately.  The CSN consists of three parts: the time, a replica ID,
137 and a change count within a single second.
138
139 H3: contextCSN
140
141 {{EX:contextCSN}} represents the current state of the provider
142 replica.  It is the largest {{EX:entryCSN}} of all entries in the
143 context such that no transaction having smaller {{EX:entryCSN}}
144 value remains outstanding.  Because the {{EX:entryCSN}} value is
145 obtained before transaction start and transactions are not committed
146 in the {{EX:entryCSN}} order, special care needed to be taken to
147 manage the proper {EX:contextCSN}} value in the transactional
148 environment.  Also, the state of the search result set is required
149 to correspond to the {{EX:contextCSN}} value returned to the consumer
150 as a sync cookie.
151
152 {{EX:contextCSN}}, the provider replica state, is stored in the
153 {{EX:syncProviderSubentry}}. The value of the {{EX:contextCSN}} is
154 transmitted to the consumer replica as a Sync Cookie. The cookie
155 is stored in the {{EX:syncreplCookie}} attribute of
156 {{EX:syncConsumerSubentry}} subentry. The consumer will use the
157 stored cookie value to represent its replica state when it connects
158 to the provider in the future.
159
160 H3: Glue Entry
161
162 Because general search filter can be used in the LDAP Sync replication,
163 an entry might be created without a parent, if the parent entry was
164 filtered out.  The LDAP Sync replication engine creates the glue
165 entries for such holes in the replica.  The glue entries will not
166 be returned in response to a search to the consumer {{slapd}}(8) if
167 manageDSAit is not set. It will be returned if it is set.
168
169 H2: Configuring slapd for LDAP Sync Replication
170
171 It is relatively simple to start providing a replicated directory
172 service with LDAP Sync replication, compared to the replication
173 with {{slurpd}}(8).  First, we should configure both the provider
174 and the consumer {{slapd}}(8) servers appropriately.  Then, start
175 the provider slapd instance first, and the consumer slapd instance
176 next.  Administrative tasks such as database copy and temporal
177 shutdown (or read-only demotion) of the provider are not required.
178
179 H3: Set up the provider slapd
180
181 There is no special {{slapd.conf}}(5) directive for the provider
182 {{slapd}}(8).  Because the LDAP Sync searches are subject to access
183 control, proper access control privileges should be set up for the
184 replicated content.
185
186 When creating a provider database from an {{TERM:LDIF}} file using
187 {{slapadd}}(8), you must create and update a state indicator of the
188 database context up to date. {{slapadd}}(8) will store the
189 {{EX:contextCSN}} in the {{EX:syncProviderSubentry}} if it is given
190 the {{EX:-w}} flag. It is also possible to create the
191 {{EX:syncProviderSubentry}} with an appropriate {{EX:contextCSN}}
192 value by directly including it in the ldif file. If {{slapadd}}(8)
193 runs without the {{EX:-w}} flag, the provided {{EX:contextCSN}}
194 will be stored. With the {{EX:-w}} flag, a new value based on the
195 current time will be stored as {{EX:contextCSN}}. {{slapcat}}(8)
196 can be used to retrieve the directory with the {{EX:contextCSN}}
197 when it is run with the {{EX:-m}} flag.
198
199 Only the BDB (back-bdb) and HDB (back-hdb) backends can perform as
200 the LDAP Sync replication provider.  LDBM (back-ldbm) currently
201 does not have the LDAP Sync protocol functionality.
202
203 H3: Set up the consumer slapd
204
205 The consumer slapd is configured by {{slapd.conf}}(5) configuration
206 file. For the configuration directives, see the {{SECT:syncrepl}}
207 section of {{SECT:The slapd Configuration File}} chapter. In the
208 configuration file, make sure the DN given in the {{EX:updatedn=}}
209 directive of the {{EX:syncrepl}} specification has permission to
210 write to the database. Below is an example {{EX:syncrepl}} specification
211 at the consumer replica:
212
213 >       syncrepl id = 1
214 >               provider=ldap://provider.example.com:389
215 >               updatedn="cn=replica,dc=example,dc=com"
216 >               binddn="cn=syncuser,dc=example,dc=com"
217 >               bindmethod=simple
218 >               credentials=secret
219 >               searchbase="dc=example,dc=com"
220 >               filter="(objectClass=organizationalPerson)"
221 >               attrs="cn,sn,ou,telephoneNumber,title,l"
222 >               schemachecking=on
223 >               scope=sub
224 >               type=refreshOnly
225 >               interval=01:00:00
226
227 In this example, the consumer will connect to the provider slapd
228 at port 389 of {{FILE:ldap://provider.example.com}} to perform a
229 polling (refreshOnly) mode of synchronization once a day.  It will
230 bind as {{EX:cn=syncuser,dc=example,dc=com}} using simple authentication
231 with password "secret".  Note that the access control privilege of
232 the DN specified by the {{EX:binddn=}} directive should be set
233 properly to synchronize the desired replica content.  The consumer
234 will write to its database with the privilege of the
235 {EX:cn=replica,dc=example,dc=com}} entry as specified by the
236 {{EX:updatedn=}} directive.  The {{EX:updatedn}} entry should have
237 write permission to the database.
238
239 The synchronization search in the example will search for entries
240 whose objectClass is organizationalPerson in the entire subtree
241 under {{EX:dc=example,dc=com}} search base inclusively. The requested
242 attributes are {{EX:cn}}, {{EX:sn}}, {{EX:ou}}, {{EX:telephoneNumber}},
243 {{EX:title}}, and {{EX:l}}. The schema checking is turned on, so
244 that the consumer {{slapd}}(8) will enforce entry schema checking
245 when it process updates from the provider {{slapd}}(8).
246
247 The LDAP Sync replication engine is backend independent. All three
248 native backends can perform as the LDAP Sync replication consumer.
249                      
250 H3: Start the provider and the consumer slapd
251
252 If the currently running provider {{slapd}}(8) already has the
253 {{EX:syncProviderSubentry}} in its database, it is not required to
254 restart the provider slapd. You don't need to restart the provider
255 {{slapd}}(8) when you start a replicated LDAP service. When you run
256 a consumer {{slapd}}(8), it will immediately perform either the
257 initial full reload if cookie is NULL or too out of date, or
258 incremental synchronization if effective cookie is provided.  In
259 the {{refreshOnly}} mode, the next synchronization session is
260 scheduled to run interval time after the completion of the current
261 session. In the {{refreshAndPersist}} mode, the synchronization
262 session is open between the consumer and provider.  The provider
263 will send update message whenever there are updates in the provider
264 replica.