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