Improve script to run ZK cleanup on all hosts
This commit is contained in:
parent
9448cf3d90
commit
6ce036f61e
|
@ -1,11 +1,15 @@
|
|||
#!/bin/bash
|
||||
# Daily vaccuum script for PVC daemons
|
||||
# Ansible managed - last modified on 2019-08-12 13:20:15
|
||||
# {{ ansible_managed }}
|
||||
|
||||
# This script cleans up the PostgreSQL databases as well as the Zookeeper
|
||||
# database. This prevents filesystem growth balooning after loong running
|
||||
# periods.
|
||||
|
||||
echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
|
||||
echo -e "$( date )" &>>/var/log/pvc/vacuum.log
|
||||
echo -e "----------------------------" &>>/var/log/pvc/vacuum.log
|
||||
|
||||
#
|
||||
# PostgreSQL
|
||||
#
|
||||
|
@ -14,15 +18,10 @@
|
|||
HOSTNAME="$( hostname -s )"
|
||||
PRIMARY="$( patronictl -c /etc/patroni/config.yml -d zookeeper://localhost:2181 list --format json \
|
||||
| jq -r '.[] | select(.Role == "Leader") | .Member' )"
|
||||
if [[ $HOSTNAME != $PRIMARY ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $HOSTNAME == $PRIMARY ]]; then
|
||||
# Analyze the database
|
||||
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
|
||||
fi
|
||||
|
||||
#
|
||||
# Zookeeper
|
||||
|
|
Loading…
Reference in New Issue