Make vacuum script more comprehensive

This commit is contained in:
Joshua Boniface 2023-09-01 15:42:21 -04:00
parent 8163769183
commit 7689e659fe
3 changed files with 27 additions and 12 deletions

View File

@ -60,12 +60,6 @@
dest: /usr/lib/check_mk_agent/plugins/postgres dest: /usr/lib/check_mk_agent/plugins/postgres
mode: 0755 mode: 0755
- name: install daily vacuum script
template:
src: patroni/pvcdns-vacuum.j2
dest: /etc/cron.daily/pvcdns-vacuum
mode: 0755
- name: install initial schema files - name: install initial schema files
copy: copy:
src: "{{ item.src }}" src: "{{ item.src }}"

View File

@ -58,4 +58,10 @@
- pvcd.service - pvcd.service
- pvcd.target - pvcd.target
- name: install daily vacuum script
template:
src: pvc/pvc-vacuum.j2
dest: /etc/cron.daily/pvc-vacuum
mode: 0755
- meta: flush_handlers - meta: flush_handlers

View File

@ -1,6 +1,14 @@
#!/bin/bash #!/bin/bash
# Daily vaccuum script for PostgreSQL databases # Daily vaccuum script for PVC daemons
# {{ ansible_managed }} # Ansible managed - last modified on 2019-08-12 13:20:15
# This script cleans up the PostgreSQL databases as well as the Zookeeper
# database. This prevents filesystem growth balooning after loong running
# periods.
#
# PostgreSQL
#
# Don't run if we aren't the Patroni primary # Don't run if we aren't the Patroni primary
HOSTNAME="$( hostname -s )" HOSTNAME="$( hostname -s )"
@ -11,7 +19,14 @@ if [[ $HOSTNAME != $PRIMARY ]]; then
fi fi
# Analyze the database # Analyze the database
echo -e "----------------------------" &>>/var/log/pvc/pdns/vacuum.log echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
echo -e "$( date )" &>>/var/log/pvc/pdns/vacuum.log echo -e "$( date )" &>>/var/log/pvc/vacuum.log
echo -e "----------------------------" &>>/var/log/pvc/pdns/vacuum.log echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
su postgres -c 'vacuumdb --verbose --analyze --all' &>>/var/log/pvc/pdns/vacuum.log su postgres -c 'vacuumdb --verbose --analyze --all' &>>/var/log/pvc/vacuum.log
#
# Zookeeper
#
export ZOOCFG=/etc/zookeeper/conf/zoo.cfg
/usr/share/zookeeper/bin/zkCleanup.sh -n 7 &>>/var/log/pvc/vacuum.log