Show Table of Contents
6.5. Setting the Database Cache Size
The database cache contains the Berkeley database index files for the database, meaning all of the
*.db
and other files used for attribute indexing by the database. This value is passed to the Berkeley DB API function set_cachesize()
.
This cache size has less of an impact on Directory Server performance than the entry cache size, but if there is available RAM after the entry cache size is set, increase the amount of memory allocated to the database cache.
The operating system also has a file system cache which may compete with the database cache for RAM usage. Refer to the operating system documentation to find information on file system cache settings and monitoring the file system cache.
Note
Instead of manually setting the entry cache size Red Hat recommends the auto-sizing feature for optimized settings based on the hardware resources. For details, see Section 6.1.1, “Manually Re-enabling the Database and Entry Cache Auto-sizing”.
To manually set the database cache size, you can use:
- the Directory Server Console (see the section called “Directory Server Console: Setting the Database Cache Size”)
- the Command Line (see the section called “Command Line: Setting the Database Cache Size”)
Directory Server Console: Setting the Database Cache Size
For example, to set the database cache to 256 megabytes:
- Start the Directory Server Console.
- Select the Configuration tab and, in the navigation tree, expand the Data icon.
- Select the Database Settings entry.
- In the LMDB Plug-in Settings tab, fill the Maximum cache size field and select the unit.
- Click.The Directory Server Console returns an
LDAP_UNWILLING_TO_PERFORM
error message when you set:- a value that is not a number.
- a value that is too big for a 32-bit signed integer (2147483647) on a 32-bit system.
- a value that is too big for a 64-bit signed integer (9223372036854775807) on a 64-bit system.
- Restart the Directory Server instance:
# systemctl restart dirsrv.target
Command Line: Setting the Database Cache Size
For example, to set the database cache to 256 megabytes:
- Update the value in the Directory Server configuration:
# ldapmodify -D "cn=Directory Manager" -W -x dn: cn=config,cn=ldbm database,cn=plugins,cn=config changetype: modify replace: nsslapd-dbcachesize nsslapd-dbcachesize: 268435456
- Restart the Directory Server instance:
# systemctl restart dirsrv.target
6.5.1. Storing the Database Cache on a RAM Disk
If your system running the Directory Server instance has enough free RAM, you can optionally store the database cache on a RAM disk for further performance improvements:
- Create a directory for the database cache and metadata on the RAM disk:
# mkdir -p /dev/shm/slapd-instance_name/
- Set the following permissions on the directory:
# chown dirsrv:dirsrv /dev/shm/slapd-instance_name/ # chmod 770 /dev/shm/slapd-instance_name/
- Stop the Directory Server instance:
# systemctl stop dirsrv@instance_name
- Edit the
/etc/dirsrv/slapd-instance_name/dse.ldif
file and set the new path in thensslapd-db-home-directory
attribute in thecn=bdb,cn=config,cn=ldbm database,cn=plugins,cn=config
entry:dn: cn=bdb,cn=config,cn=ldbm database,cn=plugins,cn=config ... nsslapd-db-home-directory: /dev/shm/slapd-instance_name/
If thensslapd-db-home-directory
attribute does not exist, add it with the new value to thecn=bdb,cn=config,cn=ldbm database,cn=plugins,cn=config
entry. - Start the Directory Server instance:
# systemctl start dirsrv@instance_name
Note
When the database cache is stored on a RAM disk, Directory Server needs to recreate it after each reboot. As a consequence, the service start and initial operations are slower until the cache is recreated.