Make vacuum script more comprehensive
This commit is contained in:
parent
273c048e6a
commit
6a29400525
|
@ -60,12 +60,6 @@
|
|||
dest: /usr/lib/check_mk_agent/plugins/postgres
|
||||
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
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
|
|
|
@ -58,4 +58,10 @@
|
|||
- pvcd.service
|
||||
- pvcd.target
|
||||
|
||||
- name: install daily vacuum script
|
||||
template:
|
||||
src: pvc/pvc-vacuum.j2
|
||||
dest: /etc/cron.daily/pvc-vacuum
|
||||
mode: 0755
|
||||
|
||||
- meta: flush_handlers
|
||||
|
|
27
roles/pvc/templates/patroni/pvcdns-vacuum.j2 → roles/pvc/templates/pvc/pvc-vacuum.j2
Normal file → Executable file
27
roles/pvc/templates/patroni/pvcdns-vacuum.j2 → roles/pvc/templates/pvc/pvc-vacuum.j2
Normal file → Executable file
|
@ -1,6 +1,14 @@
|
|||
#!/bin/bash
|
||||
# Daily vaccuum script for PostgreSQL databases
|
||||
# {{ ansible_managed }}
|
||||
# Daily vaccuum script for PVC daemons
|
||||
# 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
|
||||
HOSTNAME="$( hostname -s )"
|
||||
|
@ -11,7 +19,14 @@ if [[ $HOSTNAME != $PRIMARY ]]; then
|
|||
fi
|
||||
|
||||
# Analyze the database
|
||||
echo -e "----------------------------" &>>/var/log/pvc/pdns/vacuum.log
|
||||
echo -e "$( date )" &>>/var/log/pvc/pdns/vacuum.log
|
||||
echo -e "----------------------------" &>>/var/log/pvc/pdns/vacuum.log
|
||||
su postgres -c 'vacuumdb --verbose --analyze --all' &>>/var/log/pvc/pdns/vacuum.log
|
||||
echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
|
||||
echo -e "$( date )" &>>/var/log/pvc/vacuum.log
|
||||
echo -e "----------------------------" &>>/var/log/pvc/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
|
Loading…
Reference in New Issue