Przykładowa konfiguracja pgBouncer dla Linux

  1. Instalacja (Debian)
apt-get install pgbouncer
  1. Konfiguracja

cp /etc/pgbouncer/pgbouncer.ini /etc/pgbouncer/pgbouncer.ini.orig vim /etc/pgbouncer/pgbouncer.ini # wyczyścić wszystko i wkleić poniższą zawartość

[databases]

* =

[pgbouncer]
logfile = /var/log/postgresql/pgbouncer.log
pidfile = /var/run/postgresql/pgbouncer.pid
listen_addr = 127.0.0.1
listen_port = 6432
unix_socket_dir = /var/run/postgresql
auth_type = trust
auth_file = /etc/pgbouncer/userlist.txt
admin_users = postgres
stats_users = postgres
pool_mode = transaction

log_connections = 0
log_disconnections = 0
stats_period = 300


#;; Syslog settings
syslog = 0
syslog_facility = daemon
syslog_ident = pgbounce

#; log if client connects or server connection is made
log_connections = 0

#; log if and why connection was closed
log_disconnections = 0

#; log error messages pooler sends to clients
log_pooler_errors = 0

#; write aggregated stats into log
log_stats = 0

vim /etc/pgbouncer/userlist.txt

"postgres" ""
"edokumenty" ""
"http" ""

vim /etc/default/pgbouncer

START=1
  1. Restart usługi
/etc/init.d/pgbouncer restart
  1. Konfiguracja eDokumenty (config.inc)

W stałej "DB_NAME" zmieniamy/ustawiamy port na podany w "listen_port" (z konfiguracji pgbouncer.. dmyślnie: 6432). np.

define('DB_NAME', 'dbname=edokumenty port=6432 user=http');
  1. W przypadku skorzystania z szyfrowania scram-sha-256 w konfiguracji zmieniamy tylko
    auth_type = scram-sha-256
    

Znane problemy

W przypadku gdy mamy problemy z połączeniem na porcie 6432 należy sprawdzić logi pgbouncera. Najczęstszym problem jest brak dostępu do folderu /var/run/postgresql

Przykładowa konfiguracja pgBouncer dla Windows

[databases]

* = host=127.0.0.1 dbname=edokumenty port=5432

[pgbouncer]
logfile = C:\Program Files\PgBouncer\log\pgbouncer.log
pidfile = C:\Program Files\PgBouncer\log\pgbouncer.pid
listen_addr = 127.0.0.1
listen_port = 6432
auth_type = trust
auth_file = C:\Program Files\PgBouncer\etc\userlist.txt
admin_users = postgres
stats_users = postgres
pool_mode = transaction

log_connections = 0
log_disconnections = 0
stats_period = 300