Upgrading my OpenLDAP BDB Backend for Suse 10.3
When I upgraded from OpenSuse 10.2 to OpenSuse 10.3 I should have backed up my LDAP database as LDIF before I started. I didn't do that of course but I thought maybe I could just copy the database over and tweak the config file in /etc/openldap/slapd.conf. The OpenLDAP server, slapd, can be configured to use a few different backends for storage. The most common seems to be a Berkeley Database. On my installation the database resides in /var/lib/ldap. There are a bunch of files there, it looks like a couple log files, a DB_CONFIG file and several database files (they have the extension .bdb). I don't have exact step-by-step directions for how I fixed it but I'll go over the highlights of what worked for me. The first thing I did was make a copy of /var/lib/ldap. Then I tried copying those files from my old Suse 10.2 install to my new Suse 10.3 install and starting up slapd again. When I did that I got an error from the Berkeley Database libraries: db_stat: Program version 4.5 doesn't match environment version 4.4 db_stat: DB_ENV->open: DB_VERSION_MISMATCH: Database environment version mismatch It took a lot of digging but it seems like the "environment" they're talking about has nothing to do with environment variables or the shell (as it implied to me). The 'environment' in the error here refers to the home for the database. I found this out when trying to use db_upgrade to upgrade the database from 4.4 to 4.5. The thing is, if all you have is database files from the older version, db_upgrade seems to be unable to do anything. I copied my old files into directory called ldap44 and my new ones (that came from installing the OpenLDAP package in OpenSuse10.3) into a directory called ldap45. Then I switched to the ldap45 directory and used db_upgrade and kind of mashed them up. rcldap stop db_upgrade ../ldap44/displayName.bdb db_upgrade ../ldap44/dn2id.bdb db_upgrade ../ldap44/gidNumber.bdb db_upgrade ../ldap44/givenName.bdb db_upgrade ../ldap44/id2entry.bdb db_upgrade ../ldap44/log.0000000001 db_upgrade ../ldap44/mail.bdb db_upgrade ../ldap44/member.bdb db_upgrade ../ldap44/objectClass.bdb db_upgrade ../ldap44/sn.bdb db_upgrade ../ldap44/uid.bdb db_upgrade ../ldap44/uidNumber.bdb So this used the current directory (which contained BDB version 4.5 files) as the home (since -h isn't specified) and upgraded the named 4.4 files in place. I thought slapd should be happy with that but it wasn't. If I recall correctly, using these files let slapd start but I couldn't see my data. It's possible that I just didn't have all the files in the right spots. But slapcat doesn't need slapd running to do its job. So I used slapcat to dump out an LDIF file with the contents of the database as it existed in my ldap45 directory. slapcat -l ldif This produced a text file with all my LDAP data in LDIF format in it. You can look at it with any text editor to confirm it's got the right stuff in it. Then I put the original, empty database that came from the OpenSuse 10.3 install in to /var/lib/ldap and started up slapd. Since I was using the original blank database it started up without a problem but of course it had no data in it. Finally I imported the LDIF file I'd made using slapadd. ldapadd -X "cn=Administrator,dc=local" -f ldif This prompted me for the password for cn=Administrator,dc=local then imported all the data from the LDIF file. I'm sure there's a simpler way about this, but I haven't done much with Berkeley Databases before. Hopefully this can help out somebody out there but don't complain to me if this burns your computer down, I'm just doing a brain dump so I have some notes to refer to on my next upgrade.
Your rating: None Average: 3 (137 votes)