Compact MDB File Size
Discover effective strategies to reduce the size of your Microsoft Access MDB files for better performance and efficiency.
Date: 17-01-2022
Compacting an LMDB database using mdb_copy involves creating a new, smaller copy of the database by omitting free pages and renumbering the remaining pages sequentially. This process can reduce the overall size of the database file, especially if there has been significant data deletion or modification that has left behind many free pages.
mdb_copy is part of the mdbtools package and can be installed using:
sudo apt update
sudo apt install mdbtoolsWhile mdb_copy can create a consistent copy even with active read transactions, it is generally recommended to minimize or eliminate active write transactions during the compaction process to ensure the most up-to-date and accurate copy.
1. Stop the slapd process:
sudo systemctl stop slapd or
sudo service slapd stop 2. Make a backup location. Choose a location with enough space:
mkdir /tmp/backup3. Use mdb_copy to make a non-sparse copy of the database. -c may be used while copying to compact the mdb file. Only current data pages will be copied when using -c; freed or unused pages will be omitted from the copy. This option will slow down the backup process as it is more CPU-intensive. Currently it fails if the environment has suffered a page leak.
mdb_copy /var/symas/openldap-data/<database dir>/ /tmp/backup/or
mdb_copy -c /var/symas/openldap-data/<database dir>/ /tmp/backup/4. Remove existing .mdb files from /var/symas/openldap-data:
sudo rm -rf /var/symas/openldap-data/<database dir>/*.mdb 5. Replace with the copy that you created with mdb_copy:
sudo cp /tmp/backup/*.mdb /var/symas/openldap-data/<database dir>/6. Start solserver/slapd:
sudo systemctl start slapdor
sudo service slapd start