OpenLDAP services generate logs, whether when entries are written or when the server is part of a replication cluster.
Logs allow OpenLDAP to find its way if the database (BDB in our case) gets corrupted, for instance after a power outage. The issue is that these logs can grow enormously until they saturate the hard drive of your directory.
We will study here 2 methods that will allow you to clean up these logs.
First go to the directory containing the data of your OpenLDAP directory (/var/lib/ldap/ under Linux, /var/db/openldap-data under FreeBSD).
The manual method makes it possible to ensure everything goes well. We will first ask the archive utility to give us the names of the unneeded log files.
# db_archive-4.6
...
log.0000002515
log.0000002516
log.0000002517
log.0000002518
log.0000002519
log.0000002520
log.0000002521
Be careful, on older versions and on some distributions the binary name may vary: db_archive4.2, db42_archive…
Let’s now clean up these files with the same utility:
db_archive-4.6 -d
The automatic method is simpler but does not act instantly. Open the DB_CONFIG file (create it if it doesn’t exist) and add the following line:
set_flags DB_LOG_AUTOREMOVE
Then, restart openldap.
That’s all. You should have saved some space on your disk!