Analytics System Disk Full - Quick Fix

Sean Horn -

In cases where an Analytics system's

/var/opt/opscode-analytics

filesystem fills up and the free space cannot be increased to 50% or more to allow a VACUUM FULL, or a VACUUM FULL would take too long, the only choice is to delete rows in the activities table, export the remaining data, then drop the databases and import the data.

# export-analytics.sh

    pg_dumpall -c -g -U chef-pgsql --file=globals.sql;
psql -AtU chef-pgsql postgres -c "SELECT datname FROM pg_database \
WHERE NOT datistemplate"| \

while read f;
do pg_dump -U chef-pgsql --format=c --file=$f.sqlc $f;
done;

# import-analytics.sh

    psql postgres chef-pgsql < globals.sql
for ii in $(ls *.sqlc); do
pg_restore -C -U chef-pgsql --dbname=template1 $ii
done


# On the ailing Analytics system

    opscode-analytics-ctl stop
opscode-analytics-ctl start postgresql
    su - chef-pgsql
    psql actions chef-pgsql -c 'DELETE FROM activities where recorded_at > '2015-10-28 22:49:57+00';
    bash ./export-analytics.sh
for ii in actions notifier_config postgres; do psql template1 chef-pgsql -c "DROP DATABASE $ii;" done
bash ./import-analytics.sh

opscode-analytics-ctl restart
Have more questions? Submit a request

Comments

Powered by Zendesk