How to clean up the translog from a certain point in time
Environment
- UCS 4.4
Note 1: If you only want to reduce the database and you want to keep the last x entries check this article.
Note 2: I assume to clean everything in transog before 1st of January 2021.
Note 3: You must ensure that all servers (backups and slaves) are replicated at least to the TID you want to reduce to!
Get TID of the certain point in time and clean the translog database.
Step 1: Get the last TID of the timewindow, we want to delete out of the translog
root@dc0:~# ldapsearch -x -H ldapi:// -LLL -b cn=translog '(&(reqStart<=20210101000000Z)(reqStart>=20201201000000Z))' reqSession |tail -n 2
reqSession: 122933
Please adjust the reqStart timestamps to your needs!
My last TID in 2020 was 122933
Step 2 Check the last entry to delete
root@dc0:~ # ldapsearch -x -H ldapi:// -LLL -b reqSession=122933,cn=translog createTimestamp
dn: reqSession=122933,cn=translog
createTimestamp: 20201225203654Z
Step 3 Check the first entry to keep
root@dc0:~ # ldapsearch -x -H ldapi:// -LLL -b reqSession=122934,cn=translog createTimestamp
dn: reqSession=122934,cn=translog
createTimestamp: 20210104000805Z
Step 4 Clean up
root@dc0:~ # /usr/share/univention-directory-notifier/univention-translog -v prune 122933
2021-11-15 08:43:30,238:INFO:Index of size 1546064 contains 171784 entries
2021-11-15 08:43:30,245:INFO:Purging/keeping 1..122933..171783
2021-11-15 08:43:30,648:INFO:Removing /var/lib/univention-ldap/notify/transaction.index ...
2021-11-15 08:43:30,674:INFO:INFO:Deleted reqSession=1,cn=translog
2021-11-15 08:43:30,674:INFO:Deleted reqSession=2,cn=translog
...
2021-11-15 08:47:36,335:INFO:Deleted reqSession=122931,cn=translog
2021-11-15 08:47:36,335:INFO:Deleted reqSession=122932,cn=translog
Step 5 Clean up free pages
After that the free pages must be cleaned up. But technically that’s not required and the necessity should be considered in relation to downtime. Anyway these would be the steps:
root@ucs:~# mkdir /var/lib/univention-ldap/translog-new
root@ucs:~# systemctl stop univention-directory-notifier.service
root@ucs:~# systemctl stop slapd.service
root@ucs:~# mdb_copy -c /var/lib/univention-ldap/translog /var/lib/univention-ldap/translog-new
root@ucs:~# mv /var/lib/univention-ldap/translog /var/lib/univention-ldap/translog-old
root@ucs:~# mv /var/lib/univention-ldap/translog-new /var/lib/univention-ldap/translog
root@ucs:~# systemctl start slapd.service
root@ucs:~# systemctl start univention-directory-notifier.service
Recheck with nagios the space is freed
/usr/lib/nagios/plugins/check_univention_slapd_mdb_maxsize
For UCS5 the Bugfixes
Bug 54797
and for UCS4
Bug 55863
made a quick reindex of the notifier possible. So a reindex should be made, before the notifier was started again. Otherwise this could take lots of time in larger environments.
/usr/share/univention-directory-notifier/univention-translog reindex
see also: