2.0 KiB
pgBadger for PostgreSQL
##############################################################################
Install on PostgreSQL Servers
Using upstream postresql's repos, not Debian's repos.
#apt install
Configure postgres:
vim /etc/postgresql/10/main/postgresql.conf
Change:
log_min_duration_statement = 1000 log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' log_checkpoints = on log_connections = on log_disconnections = on log_lock_waits = on log_temp_files = 0 log_autovacuum_min_duration = 0 log_error_verbosity = default lc_messages='C'
Add user to pull logs on pg1 pg2 pg3 pg4
adduser pgbadger adduser pgbadger adm
Set up key on pgbadger node to enable it to ssh to pg1 pg2 pg3 pg4
##############################################################################
Install on Web Node
Set up Debian Stretch node
Install postgres repos:
echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' > /etc/apt/sources.list.d/pgdg.list wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - apt update apt install postgresql-client-10
apt install pgbadger libtext-csv-xs-perl libjson-xs-perl
adduser pgbadger sudo su - pgbadger ssh-keygen -t ed25519
copy that key to user pgbadger@pg1 pg2 pg3 pg4
Set up apache2
apt install apache2 rm /var/www/html/index.html chown pgbadger:pgbadger /var/www/html mkdir /var/www/html/pg1 /var/www/html/pg2 /var/www/html/pg3 /var/www/html/pg4
Set up script for user pgbadger to run:
See script: forksand-pgbadger-gen
Run that script in cron as user pgbadger:
crontab -e
m h dom mon dow command
*/5 * * * * /home/pgbadger/forksand-pgbadger-gen
##############################################################################
Admin Web Client
On workstation create tunnel:
ssh -N -C -L 55432:localhost:80 pgbadger
On workstation, in browser:
http://localhost:55432/ ##############################################################################