我将 openldap 从 openldap-2.4.39-8.el6.x86_64 升级到 2.4.40-12.el6.x86_64,重启服务器后出现以下错误。我正在尝试找出如何恢复,因为我没有备份。
586d0afc <<< dnNormalize: <cn=write>
586d0afc backend_startup_one: starting "dc=custsvc,dc=mycompany"
586d0afc bdb_db_open: "dc=custsvc,dc=mycompany"
586d0afc bdb_db_open: database "dc=custsvc,dc=mycompany": dbenv_open(/var/lib/ldap).
586d0afc bdb(dc=custsvc,dc=mycompany): file id2entry.bdb has LSN 1/720219, past end of log at 1/600
586d0afc bdb(dc=custsvc,dc=mycompany): Commonly caused by moving a database from one database environment
586d0afc bdb(dc=custsvc,dc=mycompany): to another without clearing the database LSNs, or by removing all of
586d0afc bdb(dc=custsvc,dc=mycompany): the log files from a database environment
586d0afc bdb(dc=custsvc,dc=mycompany): /var/lib/ldap/id2entry.bdb: unexpected file type or format
586d0afc bdb_db_open: database "dc=custsvc,dc=mycompany": db_open(/var/lib/ldap/id2entry.bdb) failed: Invalid argument (22).
586d0afc ====> bdb_cache_release_all
586d0afc backend_startup_one (type=bdb, suffix="dc=custsvc,dc=mycompany"): bi_db_open failed! (22)
586d0afc slapd shutdown: initiated
586d0afc ====> bdb_cache_release_all
586d0afc bdb_db_close: database "dc=custsvc,dc=mycompany": alock_close failed
586d0afc slapd destroy: freeing system resources.
586d0afc slapd stopped.
答案1
因此,在搜索了互联网之后,没有找到有效的解决方案,唯一推荐的方法似乎是db_recover -v -h /var/lib/ldap/
无效的,但我注意到它增加了恢复检查点。
[root@lddev-build-par01 ~]# db_recover -v -h /var/lib/ldap/
Finding last valid log LSN: file: 1 offset 1632
Recovery complete at Wed Jan 4 14:52:26 2017
Maximum transaction ID 0 Recovery checkpoint [1][1632]
[root@lddev-build-par01 ~]# db_recover -v -h /var/lib/ldap/
Finding last valid log LSN: file: 1 offset 1724
Recovery complete at Wed Jan 4 14:52:26 2017
Maximum transaction ID 0 Recovery checkpoint [1][1724]
因此,在确保备份了无法正常工作的数据后,我多次运行该命令,直到恢复检查点高于 BDB 文件认为存在问题的位置。我真的没想到它会起作用。
while true; do db_recover -v -h /var/lib/ldap/; done
但事实确实如此:-)
我不想保证没有数据丢失,但由于这是一个开发环境,所以这不是世界末日,测试套件很快就会发现任何问题。希望这对某些人有帮助。