Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A Mac OS X Lion 10.7.5 server running Open Directory hung. SSH was still possible but the sudo reboot command didn't restart the server within 15 minutes. That is why a power cycle was issued. After the power cycle Open Directory would no longer start and the System log is filled with a new message every 10 seconds:[1] (org.openldap.slapd[1153]): Exited with code: 1[1] (org.openldap.slapd): Throttling respawn: Will start in 10 seconds

Repairing disk permission, neither another reboot doesn't solve the issue.

Slapd in Tool mode outputs:

$ sudo /usr/libexec/slapd -Tt
bdb(dc=nl2,dc=probackup,dc=nl): unable to allocate memory for mutex; resize mutex region
bdb_db_open: database "dc=nl2,dc=probackup,dc=nl" cannot be opened, err 12. Restore from backup!
backend_startup_one (type=bdb, suffix="dc=nl2,dc=probackup,dc=nl"): bi_db_open failed! (12)
slap_startup failed (test would succeed using the -u switch)

How to fix this?

share|improve this question
up vote 10 down vote accepted

To repair the Open Directory authdata database:

$ sudo launchctl unload /System/Library/LaunchDaemons/org.openldap.slapd.plist

Now start the database recovery using the command below that matches your OS version.

$ sudo db_recover -h /var/db/openldap/authdata/ # Mac OS X 10.7
$ sudo db_recover -h /var/db/openldap/openldap-data/ # Mac OS X 10.6

Now slapd in tool mode outputs:

$ sudo /usr/libexec/slapd -Tt
bdb_db_open: database "dc=nl2,dc=probackup,dc=nl": unclean shutdown detected; attempting recovery.
bdb_db_open: database "dc=nl2,dc=probackup,dc=nl": recovery skipped in read-only mode. Run manual recovery if errors are encountered.
bdb_monitor_db_open: monitoring disabled; configure monitor database to enable
config file testing succeeded

Now turn back on Open Directory:

$ sudo launchctl load /System/Library/LaunchDaemons/org.openldap.slapd.plist

And issue another restart to be better safe than sorry:

$ sudo reboot

Open Directory is now up and running again.

share|improve this answer
This approach didn't exactly do the trick for me, but it set me on the right track. I don't really know what I'm doing with LDAP administration, so YMMV, but after running this command, I was able to restart slapd and my data hadn't been lost: sudo db_recover -h /var/db/openldap/openldap-data/. It seems like a different BDB database structure associated with LDAP had been corrupted in my particular case, so may be worth investigating if the above doesn't work for you. Good luck! – Justin Leitgeb Apr 30 '15 at 14:47

This is how I usually repair a broken LDAP/OD

1. check if this is the problem

sudo /usr/libexec/slapd -Tt*

You might get: bdb_db_open: database "cn=authdata": db_open(/var/db/openldap/authdata/id2entry.bdb) failed: Invalid argument (22).

2. Stop LDAP on OD Master

sudo launchctl unload /System/Library/LaunchDaemons/org.openldap.slapd.plist

3. Repair Permissions

diskutil repairPermissions /

4. backup openldap db

sudo cp /var/db/openldap/authdata/id2entry.bdb /var/db/openldap/authdata/id2entry.bdb.backup

5. repair

sudo db_recover -cv -h /var/db/openldap/openldap-data/

6. run repair again to check

sudo db_recover -cv -h /var/db/openldap/openldap-data/

7. do it one more time so things are repaired correctly

sudo /usr/libexec/slapd -Tt

8. restart the service

sudo launchctl load /System/Library/LaunchDaemons/org.openldap.slapd.plist

9. If the above does not work, try:

sudo db_recover -cv -h /var/db/openldap/authdata/

then I restart the service with step 8.

sudo launchctl load /System/Library/LaunchDaemons/org.openldap.slapd.plist

This usually fixes the problem... but in some cases you need to restore like llange explaines in his post.

share|improve this answer

First best is to check the disk you may do so either using the recovery partition or single user (cmd - S at startup) then type :

fsck -fy

QWERTY keyboard the dash is 2 key left from backspace.

To re-import a corrupted database from a backup you should backup and replace the following files/ folders :

  • var/db/openldap/
  • usr/bin/db_recover

Not sure it's necessary but if you have removed the LDAPv3 entry in the System keychain :

  • Library/Keychains/System.keychain

The try a recovery…

Then you should repair disk permissions from a terminal (not single user) :

diskutil repairPermissions /

If after the recovery you experience problem connecting to services check the configuration under "Services" tab in Directory Utility.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.