parent
c9e8c4cf55
commit
c87cc5ff22
@ -0,0 +1,70 @@
|
|||||||
|
# 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/
|
||||||
|
##############################################################################
|
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# forksand-pgbadger-gen
|
||||||
|
|
||||||
|
pgbadger \
|
||||||
|
--remote-host pg1 \
|
||||||
|
--incremental \
|
||||||
|
--jobs 4 \
|
||||||
|
--outdir /var/www/html/pg1 \
|
||||||
|
--retention 8 \
|
||||||
|
--extra-files \
|
||||||
|
--ssh-user pgbadger \
|
||||||
|
--prefix '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' \
|
||||||
|
/var/log/postgresql/postgresql-10-main.log
|
||||||
|
|
||||||
|
pgbadger \
|
||||||
|
--remote-host pg2 \
|
||||||
|
--incremental \
|
||||||
|
--jobs 4 \
|
||||||
|
--outdir /var/www/html/pg2 \
|
||||||
|
--retention 8 \
|
||||||
|
--extra-files \
|
||||||
|
--ssh-user pgbadger \
|
||||||
|
--prefix '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' \
|
||||||
|
/var/log/postgresql/postgresql-10-main.log
|
||||||
|
|
||||||
|
pgbadger \
|
||||||
|
--remote-host pg3 \
|
||||||
|
--incremental \
|
||||||
|
--jobs 4 \
|
||||||
|
--outdir /var/www/html/pg3 \
|
||||||
|
--retention 8 \
|
||||||
|
--extra-files \
|
||||||
|
--ssh-user pgbadger \
|
||||||
|
--prefix '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' \
|
||||||
|
/var/log/postgresql/postgresql-10-main.log
|
||||||
|
|
||||||
|
pgbadger \
|
||||||
|
--remote-host pg4 \
|
||||||
|
--incremental \
|
||||||
|
--jobs 4 \
|
||||||
|
--outdir /var/www/html/pg4 \
|
||||||
|
--retention 8 \
|
||||||
|
--extra-files \
|
||||||
|
--ssh-user pgbadger \
|
||||||
|
--prefix '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' \
|
||||||
|
/var/log/postgresql/postgresql-10-main.log
|
Binary file not shown.
Loading…
Reference in new issue