source: branches/fc13-dev/server/doc/install-ldap @ 1681

Last change on this file since 1681 was 1680, checked in by ezyang, 14 years ago
More updates to LDAP instructions.
File size: 12.4 KB
Line 
1To set up a new LDAP server:
2
3- Install the RPM 389-ds-base with yum (these are installed by kickstart
4  these days, so these two steps are probably not necessary)
5  root# yum install -y 389-ds-base
6  root# yum install -y policycoreutils-python
7  root# yum install -y ldapvi
8- We want to run the directory server as its own user, so create fedora-ds
9  root# useradd -r -d /var/lib/dirsrv fedora-ds
10- Temporarily move away the existing slapd-scripts folder
11  root# mv /etc/dirsrv/slapd-scripts{,.bak}
12- root# /usr/sbin/setup-ds.pl
13    - Choose a typical install
14    - Tell it to use the fedora-ds user and group
15    - Directory server identifier: scripts
16        Needed to remove this from the config file first
17    - Suffix: dc=scripts,dc=mit,dc=edu
18    - Input directory manager password
19      (this can be found in  ~/.ldapvirc)
20- Move the schema back
21  root# cp -R /etc/dirsrv/slapd-scripts.bak/{.svn,*} /etc/dirsrv/slapd-scripts
22  root# rm -Rf /etc/dirsrv/slapd-scripts.bak
23- Turn dirsrv off: service dirsrv stop
24- Apply the following configuration changes.  If you're editing
25  dse.ldif, you don't want dirsrv to be on, otherwise it will
26  overwrite your changes. [XXX: show how to do these changes with
27  dsconf, which is the "blessed" method]
28
29# Inside cn=config.  These changes definitely require a restart.
30nsslapd-ldapifilepath: /var/run/dirsrv/slapd-scripts.socket
31nsslapd-ldapilisten: on
32
33# Add these blocks
34
35# mapname, mapping, sasl, config
36# This is the most liberal mapping you can have for SASL: you can
37# basically add authentication for any given GSSAPI mechanism by
38# explicitly creating the UID for that SASL string.
39dn: cn=mapname,cn=mapping,cn=sasl,cn=config
40objectClass: top
41objectClass: nsSaslMapping
42cn: mapname
43nsSaslMapRegexString: \(.*\)
44nsSaslMapBaseDNTemplate: uid=\1,ou=People,dc=scripts,dc=mit,dc=edu
45nsSaslMapFilterTemplate: (objectClass=posixAccount)
46
47- Put LDAP keytab (ldap/hostname.mit.edu) in /etc/dirsrv/keytab.  Make
48  sure you chown/chgrp it to be readable by fedora-ds
49- Uncomment and modify in /etc/sysconfig/dirsrv: KRB5_KTNAME=/etc/dirsrv/keytab ; export KRB5_KTNAME
50- chown fedora-ds:fedora-ds /var/run/dirsrv
51- chmod 755 /var/run/dirsrv
52- /sbin/service dirsrv start
53- Use ldapvi -b cn=config to add these indexes (8 of them):
54
55add cn=apacheServerName, cn=index, cn=userRoot, cn=ldbm database, cn=plugins, cn=config
56objectClass: top
57objectClass: nsIndex
58cn: apacheServerName
59nsSystemIndex: false
60nsIndexType: eq
61nsIndexType: pres
62
63add cn=apacheServerAlias, cn=index, cn=userRoot, cn=ldbm database, cn=plugins, cn=config
64objectClass: top
65objectClass: nsIndex
66cn: apacheServerAlias
67nsSystemIndex: false
68nsIndexType: eq
69nsIndexType: pres
70
71add cn=scriptsVhostName, cn=index, cn=userRoot, cn=ldbm database, cn=plugins, cn=config
72objectClass: top
73objectClass: nsIndex
74cn: scriptsVhostName
75nsSystemIndex: false
76nsIndexType: eq
77nsIndexType: pres
78
79add cn=scriptsVhostAlias, cn=index, cn=userRoot, cn=ldbm database, cn=plugins, cn=config
80objectClass: top
81objectClass: nsIndex
82cn: scriptsVhostAlias
83nsSystemIndex: false
84nsIndexType: eq
85nsIndexType: pres
86
87add cn=scriptsVhostAccount, cn=index, cn=userRoot, cn=ldbm database, cn=plugins, cn=config
88objectClass: top
89objectClass: nsIndex
90cn: scriptsVhostAccount
91nsSystemIndex: false
92nsIndexType: eq
93nsIndexType: pres
94
95add cn=memberuid, cn=index, cn=userRoot, cn=ldbm database, cn=plugins, cn=config
96objectClass: top
97objectClass: nsIndex
98cn: memberuid
99nsSystemIndex: false
100nsIndexType: eq
101nsIndexType: pres
102
103add cn=uidnumber, cn=index, cn=userRoot, cn=ldbm database, cn=plugins, cn=config
104objectClass: top
105objectClass: nsIndex
106cn: uidnumber
107nsSystemIndex: false
108nsIndexType: eq
109nsIndexType: pres
110
111add cn=gidnumber, cn=index, cn=userRoot, cn=ldbm database, cn=plugins, cn=config
112objectClass: top
113objectClass: nsIndex
114cn: gidnumber
115nsSystemIndex: false
116nsIndexType: eq
117nsIndexType: pres
118
119- Build the indexes for all the fields:
120
121    /usr/lib64/dirsrv/slapd-scripts/db2index.pl -D "cn=Directory Manager" -j /etc/signup-ldap-pw -n userRoot
122
123  (/etc/signup-ldap-pw is the LDAP root password, make sure it's
124  chmodded correctly and chowned to signup. Also, make sure it doesn't
125  have a trailing newline!)
126
127-  Watch for the indexing operations to finish with this command:
128
129    ldapsearch -x -y /etc/signup-ldap-pw -D 'cn=Directory Manager' -b cn=tasks,cn=config
130
131  (look for nktaskstatus)
132
133- Set up replication.
134
135  We used to tell people to go execute
136  http://directory.fedoraproject.org/sources/contrib/mmr.pl manually
137  (manually because that script assumes only two masters and we have
138  every one of our servers set up as a master.)  However, those
139  instructions are inaccurate, because we use GSSAPI, not SSL and
140  because the initializing procedure is actually prone to a race
141  condition.  Here are some better instructions.
142
143  LDAP replication is based around producers and consumers.  Producers
144  push changes in LDAP to consumers: these arrangements are called
145  "replication agreements" and the producer will hold a
146  nsDS5ReplicationAgreement object that represents this commitment,
147  as well as some extra configuration to say who consumers will accept
148  replication data from (a nsDS5Replica).
149
150  The procedure, at a high level, is this:
151
152    1. Pick an arbitrary existing master.  The current server will
153       be configured as a slave to that master.  Initialize a changelog,
154       then request a replication to populate our server with
155       information.
156
157            M1 <---> M2 ---> S
158
159    2. Configure the new server to be replicated back.
160
161            M1 <---> M2 <---> S
162
163    3. Set up the rest of the replication agreements at your leisure.
164
165                M1 <---> M2
166                ^         ^
167                |         |
168                +--> S <--+
169
170  Here's how you do it.
171
172    1. Pull open the replication part of the database. It's fairly empty
173       right now.
174
175        ldapvi -b cn=\"dc=scripts,dc=mit,dc=edu\",cn=mapping\ tree,cn=config
176
177    2. Configure the server $SLAVE (this server) to accept $MASTER
178       replications by adding the following LDAP entries:
179
180add cn=replica, cn="dc=scripts,dc=mit,dc=edu", cn=mapping tree, cn=config
181objectClass: top
182objectClass: nsDS5Replica
183cn: replica
184nsDS5ReplicaId: $REPLICA_ID
185nsDS5ReplicaRoot: dc=scripts,dc=mit,dc=edu
186nsDS5Flags: 1
187nsDS5ReplicaBindDN: uid=ldap/bees-knees.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
188nsDS5ReplicaBindDN: uid=ldap/busy-beaver.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
189nsDS5ReplicaBindDN: uid=ldap/cats-whiskers.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
190nsDS5ReplicaBindDN: uid=ldap/pancake-bunny.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
191nsDS5ReplicaBindDN: uid=ldap/whole-enchilada.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
192nsDS5ReplicaBindDN: uid=ldap/real-mccoy.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
193nsDS5ReplicaBindDN: uid=ldap/better-mousetrap.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
194nsDS5ReplicaBindDN: uid=ldap/old-faithful.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
195# ADD SERVERS HERE AS YOU ADD NEW SERVERS
196nsds5ReplicaPurgeDelay: 604800
197nsds5ReplicaLegacyConsumer: off
198nsDS5ReplicaType: 3
199
200        $REPLICA_ID is the scripts$N number (stella $HOSTNAME to find
201        out.)  You might wonder why we are binding to all servers;
202        weren't we going to replicate from only one server?  That is
203        correct, however, simply binding won't mean we will receive
204        updates; we have to setup the $MASTER to send data $SLAVE.
205
206    3. Although we allowed those uids to bind, that user information
207       doesn't exist on $SLAVE yet.  So you'll need to create the entry
208       for just $MASTER.
209
210add uid=ldap/$MASTER,ou=People,dc=scripts,dc=mit,dc=edu
211uid: ldap/$MASTER
212objectClass: account
213objectClass: top
214
215    4. Though our $SLAVE will not be making changes to LDAP, we need to
216       initialize the changelog because we intend to be able to do this
217       later.
218
219add cn=changelog5,cn=config
220objectclass: top
221objectclass: extensibleObject
222cn: changelog5
223nsslapd-changelogdir: /etc/dirsrv/slapd-scripts/changelogdb
224
225    5. Ok, now go to your $MASTER server that you picked (it should have
226       been one of the hosts mentioned in nsDS5ReplicaBindDN) and tell
227       it to replicate to $SLAVE.
228
229       The last line runs the replication.  This is perhaps the most
230       risky step of the process; see below for help debugging problems.
231
232       WARNING: There is a known bug doing full updates from 1.2.6 to
233       1.2.6, see https://bugzilla.redhat.com/show_bug.cgi?id=637852
234
235add cn="GSSAPI Replication to $SLAVE", cn=replica, cn="dc=scripts,dc=mit,dc=edu", cn=mapping tree, cn=config
236objectClass: top
237objectClass: nsDS5ReplicationAgreement
238cn: "GSSAPI Replication to $SLAVE"
239cn: GSSAPI Replication to $SLAVE
240nsDS5ReplicaHost: $SLAVE
241nsDS5ReplicaRoot: dc=scripts,dc=mit,dc=edu
242nsDS5ReplicaPort: 389
243nsDS5ReplicaTransportInfo: LDAP
244nsDS5ReplicaBindDN: uid=ldap/$MASTER,ou=People,dc=scripts,dc=mit,dc=edu
245nsDS5ReplicaBindMethod: SASL/GSSAPI
246nsDS5ReplicaUpdateSchedule: "0000-2359 0123456"
247nsDS5ReplicaTimeout: 120
248nsDS5BeginReplicaRefresh: start
249
250    5. Check that the replication is running; the status will be stored
251    in the object we've been mucking around with.
252
253    If it fails with LDAP Error 49, check /var/log/dirsrv on $MASTER
254    for more information.  It might be because fedora-ds can't read
255    /etc/dirsrv/keytab
256
257    6. Replicate in the other direction.  On $MASTER, add $SLAVE
258    as a nsDS5ReplicaBindDN in cn=replica,cn="dc=scripts,dc=mit,dc=edu",cn=mapping tree,cn=config
259    Also, add an account for $SLAVE
260
261add uid=ldap/$SLAVE,ou=People,dc=scripts,dc=mit,dc=edu
262uid: ldap/$SLAVE
263objectClass: account
264objectClass: top
265
266    On $SLAVE,
267
268add cn="GSSAPI Replication to $MASTER", cn=replica, cn="dc=scripts,dc=mit,dc=edu", cn=mapping tree, cn=config
269objectClass: top
270objectClass: nsDS5ReplicationAgreement
271cn: "GSSAPI Replication to $MASTER"
272cn: GSSAPI Replication to $MASTER
273nsDS5ReplicaHost: $MASTER
274nsDS5ReplicaRoot: dc=scripts,dc=mit,dc=edu
275nsDS5ReplicaPort: 389
276nsDS5ReplicaTransportInfo: LDAP
277nsDS5ReplicaBindDN: uid=ldap/$SLAVE,ou=People,dc=scripts,dc=mit,dc=edu
278nsDS5ReplicaBindMethod: SASL/GSSAPI
279nsDS5ReplicaUpdateSchedule: "0000-2359 0123456"
280nsDS5ReplicaTimeout: 120
281
282    If you get a really scary internal server error, that might mean you
283    forgot to initialize the changelog.  Remove the replication
284    agreement (you'll need to turn off dirsrv), add the changelog, and
285    then try again.
286
287Troubleshooting
288===============
289
290LDAP multimaster replication can fail in a number of colorful ways;
291combine that with GSSAPI authentication and it goes exponential.
292
293If authentication is failing with LDAP error 49, check if:
294
295    * /etc/dirsrv/keytab
296    * fedora-ds is able to read /etc/dirsrv/keytab
297    * /etc/hosts has not been modified by Network Manager (you
298      /did/ uninstall it, right? Right?)
299
300If the failure is local to a single master, usually you can recover
301by asking another master to refresh that master with:
302
303nsDS5BeginReplicaRefresh: start
304
305In practice, we've also had problems with this technique.  Some of them
306include:
307
308* Something like https://bugzilla.redhat.com/show_bug.cgi?id=547503
309  on Fedora 11 ns-slapd, where replication is turned off to do the
310  replication, but then it wedges and you need to forcibly kill the
311  process.
312
313* Failed LDAP authentication because another master attempted to do
314  an incremental update.
315
316* Repropagation of the error because the corrupt master thinks it still
317  should push updates.
318
319So the extremely safe method to bring up a crashed master is as follows:
320
3211. Disable all incoming and outgoing replication agreements by editing
322   /etc/dirsrv/slapd-scripts/dse.ldif. You'll need to munge:
323
324   nsDS5ReplicaBindDN in cn=replica,cn=dc\3Dscripts\2Cdc\3Dmit\2Cdc\3Dedu,cn=mapping tree,cn=config
325
326   and all of the push agreements.  Deleting them outright works, but
327   means you'll have to reconstruct all of the agreements from scratch.
328
3292. Bring up the server.
330
3313. Accept incoming replication data from a single server.
332
3334. Initiate a full update from that server.
334
3355. Finish setting up replication as described above.
336
337If your database gets extremely fucked, other servers may not be able
338to authenticate because your authentication information has gone missing.
339In that case, the minimal set of entries you need is:
340
341add dc=scripts,dc=mit,dc=edu
342objectClass: top
343objectClass: domain
344dc: scripts
345
346add ou=People,dc=scripts,dc=mit,dc=edu
347objectClass: top
348objectClass: organizationalunit
349ou: People
350
351add uid=ldap/whole-enchilada.mit.edu,ou=People,dc=scripts,dc=mit,dc=edu
352objectClass: account
353objectClass: top
354uid: ldap/whole-enchilada.mit.edu
Note: See TracBrowser for help on using the repository browser.