(Answer) (Category) OpenLDAP Faq-O-Matic : (Category) OpenLDAP Software FAQ : (Category) Maintenance : (Answer) How to maintain Berkeley DB (logs etc.) ?

Berkeley DB log files grow, and the administrator has to deal with it. The procedure is known as log file archival or log file rotation. Please NOTE THAT ACTUAL LOG FILE ROTATION is handled by the Berkeley DB engine.

Logs of current transactions need to be stored into files so that the database can be recovered in the event of an application crash. Administrator can change the size limit of a single log file (by default 10MB), and have old log files removed automatically, by setting up DB environment (see below). The reason Berkeley DB never deletes any log files by default is that the administrator may wish to backup the log files before removal to make database recovery possible even after a catastrophic failure, such as file system corruption.

Log file names are log.XXXXXXXXXX (X is a digit). By default the log files are located in the BDB backend directory. The db_archive tool knows what log files are used in current transactions, and what are not. Administrators can move unused log files to a backup media, and delete them. To have them removed automatically, place set_flags DB_LOG_AUTOREMOVE directive in DB_CONFIG. Note that if the log files are removed automatically, recovery after a catastrophic failure is likely to be impossible.

The files with names __db.001, __db.002, etc are just shared memory regions (or whatever). These ARE NOT `logs', they must be left alone. Don't be afraid of them, they do not grow like logs do.

To understand the db_archive interface, reader should refer to chapter 9 of the Berkeley DB guide. In particular, the following chapters are recommended:

Advanced installations can use special environment settings to fine-tune some Berkeley DB options (change the log file limit, etc). This can be done by using DB_CONFIG file. This magic file can be created in BDB backend directory set up by slapd.conf(5). More information on this file can be found in File naming chapter. Specific directives can be found in C Interface, look for DB_ENV->set_XXXX calls.

WARNING: options set in DB_CONFIG file override options set by OpenLDAP. Use them with extreme caution. Do not use them unless You know what You are doing.

The advantages of DB_CONFIG usage can be the following:

  • to keep data files and log files on different mediums (i.e. disks) to improve performance and/or reliability;
  • to fine-tune some specific options (such as shared memory region sizes);
  • to set the log file limit (please read Log file limits before doing this).

To figure out the best-practice BDB backup scenario reader is highly recommended to read the whole Chapter 9: Berkeley DB Transactional Data Store Applications. This chapter is a set of small pages with examples in C language. Non-prorgamming people can skip this examples without loss of knowledge.


When having problems with the bdb logs (notably logs growth rate), one may check that slapd bdb parameters are configured properly. See man slapd-bdb for details.
Suggestions on logging mechanism tunig might be to adjust checkpoint parameter (so that data and logs are synchronised at some time without waiting for slapd to terminate), for instance. Also the size of the log buffers may be of importance. See http://www.openldap.org/faq/data/cache/893.html for useful details.
olivier.berger@int-evry.fr
Oracle have moved their site around, and so now the old links are broken. The Berkeley DB reference guide is here:
http://docs.oracle.com/cd/E17076_03/html/programmer_reference/index.html
stuartl@vrt.com.au
[Append to This Answer]
Previous: (Answer) How do I export my directory in LDIF format?
Next: (Answer) Why isn't checkpointing working?
This document is: http://www.openldap.org/faq/index.cgi?file=738
[Search] [Appearance]
This is a Faq-O-Matic 2.721.test.
© Copyright 1998-2013, OpenLDAP Foundation, info@OpenLDAP.org