30 July 2006

More OpenLDAP recovery...

I accidentally killed power to my Linux box while I was plugging in a new router. No biggie, except OpenLDAP wouldn't start again at reboot because the database got corrupted. I'm beginning to think that trying to use ldap as an address book just isn't worth it.

Anyway, problem resolved, thanks to PaulHowarth/Blog.

Here's the error I was getting:

[root@ldap]# /etc/rc.d/init.d/ldap start
Checking configuration files for slapd: bdb_db_open: unclean shutdown detected; attempting recovery.
bdb_db_open: Recovery skipped in read-only mode. Run manual recovery if errors are encountered.
bdb_db_open: Database cannot be opened, err 13. Restore from backup!
bdb(dc=mydomain,dc=com): DB_ENV->lock_id_free interface requires an environment configured for the locking subsystem
backend_startup_one: bi_db_open failed! (13)
slap_startup failed (test would succeed using the -u switch)
stale lock files may be present in /var/lib/ldap [WARNING]

Here's how the database was repaired:

[root@ldap]# /usr/sbin/slapd_db_recover -v -h /var/lib/ldap
Finding last valid log LSN: file: 1 offset 5315883
Recovery starting from [1][5315755]
Recovery complete at Sun Jul 30 11:31:56 2006
Maximum transaction ID 8000040d Recovery checkpoint [1][5315883]

I also used the notes from PaulHowarth/Blog to add a checkpoint directive to slapd.conf.