LDAP database recovery

公司的一台 LDAP server (FreeBSD)傍晚時因為某些原因所以緊急重開,重開後發現 slapd 跑不起來。

# /usr/local/etc/rc.d/slapd start
/usr/local/etc/rc.d/slapd: WARNING: failed to start slapd

原本以為可能是 ram 出問題導致靈異,仔細一看又不太像。

用 -d 下去跑發現…

# /usr/local/libexec/slapd -u ldap -g ldap -d -1
...
...
(中間省略)
...
...
5228a6a1 bdb_db_open: database "dc=XXX,dc=com": dbenv_open(/var/db/openldap-data).
5228a6a1 bdb_db_open: database "dc=XXX,dc=com" cannot be opened, err 22. Restore from backup!
5228a6a1 ====> bdb_cache_release_all
5228a6a1 bdb(dc=XXX,dc=com): txn_checkpoint interface requires an environment configured for the transaction subsystem
5228a6a1 bdb_db_close: database "dc=XXX,dc=com": txn_checkpoint failed: Invalid argument (22).
5228a6a1 backend_startup_one (type=bdb, suffix="dc=XXX,dc=com"): bi_db_open failed! (22)
5228a6a1 slapd shutdown: initiated
5228a6a1 ====> bdb_cache_release_all
5228a6a1 bdb_db_close: database "dc=XXX,dc=com": alock_close failed
5228a6a1 slapd destroy: freeing system resources.
5228a6a1 slapd stopped.

看起來就是 ldap db 爛了…

用 db_recover 來試著修修看(不同版本 bdb 的 db_recover 代不同版號),修的好就沒問題,修不好就得從備份撈

# /usr/local/bin/db_recover-4.6 -v -h /var/db/openldap-data/
Finding last valid log LSN: file: 1 offset 4541603
Recovery starting from [1][4541458]
Recovery complete at Thu Sep  5 23:48:00 2013
Maximum transaction ID 800000ec Recovery checkpoint [1][4541603]

然後再跑一次 slapd

# /usr/local/etc/rc.d/slapd start
Starting slapd.

就跑起來啦~~

分類: Computer, FreeBSD, Linux, Software, Sundries,標籤: , , 。這篇內容的永久連結

發表迴響