1

Topic: Power Cut Ldap dont start

OpenLdap dont start i try a lot of commands from forums to recover database but not work

I provide the exit when start ldap

Any hellp will be appreciated !  thanks

==== Provide required information ====
- iRedMail version and backend (LDAP/MySQL/PGSQL):
openldap-2.3.43-12.el5
mysql-server-5.0.77-4.el5_5.3

- Linux/BSD distribution name and version:
CentOS release 5.4 (Final)

- Any related log? Log is helpful for troubleshooting.

[root@mailserver var]# /etc/init.d/ldap start
Verificando los archivos de configuración para slapd:  bdb(dc=XXXXX,dc=xxx,dc=mx): Lock table is out of available locker entries
bdb_db_open: db_open(/var/lib/ldap/XXXX.xxx.mx/id2entry.bdb) failed: Cannot allocate memory (12)
bdb(dc=uhipocrates,dc=edu,dc=mx): Unknown locker ID: 0
backend_startup_one: bi_db_open failed! (12)
slap_startup failed (test would succeed using the -u switch)
                                                           [FALLÃ]
puede haber archivos bloqueados viciados en /var/lib/ldap/XX[AVISO]XX.xxx.mx
[root@mailserver var]#


----------------
[root@mailserver var]# slapd -u ldap -g ldap -d 256
@(#) $OpenLDAP: slapd 2.3.43 (Mar 31 2010 04:02:15) $
    mockbuild@builder16.centos.org:/builddir/build/BUILD/openldap-2.3.43/openldap-2.3.43/build-servers/servers/slapd
bdb(dc=uhipocrates,dc=edu,dc=mx): Lock table is out of available locker entries
bdb_db_open: db_open(/var/lib/ldap/XXXXXX.xxx.mx/id2entry.bdb) failed: Cannot allocate memory (12)
bdb(dc=XXXXXX,dc=xx,dc=mx): Unknown locker ID: 0
backend_startup_one: bi_db_open failed! (12)
bdb_db_close: alock_close failed
slapd stopped.
connections_destroy: nothing to destroy.

====

[root@mailserver var]# slapd_db_recover -v
Finding last valid log LSN: file: 1 offset 28

2

Re: Power Cut Ldap dont start

Show me output of command:

# ls -l /var/lib/ldap/xxx/

In iRedMail-0.8.0 and later versions, iRedMail will add backup scripts in cron job after installation complete, it's backed up in /var/vmail/backup/ by default. So if you have daily backup of your LDAP data, you can restore it by following this wiki tutorial:
http://www.iredmail.org/wiki/index.php? … _LDIF_file

If you don't have daily backup, I have two solutions to solve similar issues, but not sure whether it works for you or not. Paste here for your reference. Looks like case #2 is similar to your issue.

WARNING: backup /var/lib/ldap/ first before you try below solutions.

Case #1: Error caused by removing log.000*

Error log if you removed /var/lib/ldap/example.com/log.000*:

$OpenLDAP: slapd 2.4.26 (Feb 13 2012 09:34:08) $  @amd64.ports.openbsd.org:/usr/obj/ports/openldap-2.4.26/build-amd64/servers/slapd
slapd[15047]: bdb(dc=example,dc=com): file id2entry.bdb has LSN 119/7525342, past end of log at 1/656
slapd[15047]: bdb(dc=example,dc=com): Commonly caused by moving a database from one database environment
slapd[15047]: bdb(dc=example,dc=com): to another without clearing the database LSNs, or by removing all of
slapd[15047]: bdb(dc=example,dc=com): the log files from a database environment
slapd[15047]: bdb(dc=example,dc=com): /var/lib/ldap/example.com/id2entry.bdb: unexpected file type or format
slapd[15047]: bdb_db_open: database "dc=example,dc=com": db_open(/var/lib/ldap/example.com/id2entry.bdb) failed: Invalid argument (22).
slapd[15047]: backend_startup_one (type=bdb, suffix="dc=example,dc=com"): bi_db_open failed! (22)
slapd[15047]: bdb_db_close: database "dc=example,dc=com": alock_close failed
slapd[15047]: DIGEST-MD5 common mech free
slapd[15047]: slapd stopped.

It says "id2entry.bdb: unexpected file type or format", so we can recover it with below steps:

# cd /var/lib/ldap/example.com/
# db4_dump id2entry.bdb > /root/id2entry.bdb.dump
# rm id2entry.bdb
# db4_load id2entry.bdb < /root/id2entry.bdb.dump

Note: id2entry.bdb.dump is a plain text will very long line. it maybe grow to several GB.

Case #2: Error caused by incorrect power down

OpenLDAP error log:

bdb(dc=seecq,dc=com): /var/db/openldap-data/id2entry.bdb: unexpected file type or format
bdb_db_open: db_open( /var/db/openldap-data/id2entry.bdb) failed: Invalid argument (22)

Recover from log.*:

# db4_recover -cv

Note: It uses command 'db4_recover' provided by Berkeley DB, not OpenLDAP. And the command name may be slightly different on different Linux/BSD distributions.

Hope it helps.

Also, please add parameter checkpoint in /etc/openldap/slapd.conf if you don't have it:

database xxx
...

# This directive specifies how often to checkpoint the BDB transaction log.                                                   
# A checkpoint operation flushes the database buffers to disk and writes a         
# checkpoint record in the log. The checkpoint will occur if either <kbyte>        
# data has been written or <min> minutes have passed since the last checkpoint. 
# Both arguments default to zero, in which case they are ignored. When the         
# <min> argument is non-zero, an internal task will run every <min> minutes        
# to perform the checkpoint. See the Berkeley DB reference guide for more          
# details.                                                                         
#                                                                                  
# OpenLDAP default is NO CHECKPOINTING.                                            
#                                                                                  
# whenever 128kb data bytes written or 5 minutes has elapsed                       
checkpoint  128 5

This parameter doesn't present in iRedMail-0.8.1 and earlier versions, but it will be added by default in next release of iRedMail, v0.8.2. And will be mentioned in upgrade tutorial of upgrading iRedMail from 0.8.1 to 0.8.2 (It's still a DRAFT, do not apply them to upgrade your iRedMail-0.8.1 right now).

----

Buy me a cup of coffee ($5) to support iRedMail:

buy me a cup of coffee