如果系统突然掉电或重启引起LDAP数据库意外关闭,可能会造成下次启动时失败 ....
启动时(slapd -d 9)的错误信息如下:
Nov 23 11:22:00 dev1 slapd[22700]: bdb_db_open: unclean shutdown
detected; attem pting recovery.
Nov 23 11:22:00 dev1 slapd[22700]: bdb_db_open: dbenv_open(/var/ldap/openldap-data)
Nov 23 11:22:00 dev1 slapd[22700]: bdb(o=mycompany): Berkeley DB library
configured to support only private environments
Nov 23 11:22:00 dev1 slapd[22700]: bdb_db_open: Recovery needed but
environment is missing - assuming recovery was done manually...
Nov 23 11:22:00 dev1 slapd[22700]: bdb(o=mycompany): Berkeley DB library
configured to support only private environments
Nov 23 11:22:00 dev1 slapd[22700]: bdb_db_open: dbenv_open failed: Invalid argument (22)
Nov 23 11:22:00 dev1 slapd[22700]: backend_startup_one: bi_db_open failed! (22)
Nov 23 11:22:00 dev1 slapd[22700]: slapd shutdown: initiated
Nov 23 11:22:00 dev1 slapd[22700]: ==> unique_close
Nov 23 11:22:00 dev1 slapd[22700]: slapd destroy: freeing system resources.
Nov 23 11:22:00 dev1 slapd[22700]: slapd stopped.
Nov 23 11:22:00 dev1 slapd[22700]: connections_destroy: nothing to destroy.
此时就需要手动进行恢复了,步骤如下:
进入LDAP的数据库目录,运行 db_recover ,然后删除 alock 文件,再启动slapd即可。