make и make install прошли успешно.
Но для самосборной версии нужно:
- сделать конфиг
- создать скрипт запуска в /etc/init.d/
Конфиг: (/etc/pgBouncer/pgbouncer.ini)
;; database name = connect string [databases] test = host=127.0.0.1 port=5432 dbname=test ;;ОБЯЗАТЕЛЬНО db postgres postgres= host=127.0.0.1 port=5432 dbname=postgres ; foodb over unix socket foodb = ; redirect bardb to bazdb on localhost ;bardb = host=127.0.0.1 dbname=bazdb ; acceess to dest database will go with single user ;forcedb = host=127.0.0.1 port=300 user=baz password=foo client_encoding=UNICODE datestyle=ISO connect_query='SELECT 1' nondefaultdb = pool_size=50 reserve_pool=10 ; fallback connect string ;* = host=testserver ;; Configuation section [pgbouncer] ;;; ;;; Administrative settings ;;; logfile = /var/log/pgBouncer/pgbouncer.log pidfile = /var/run/postgresql/pgbouncer.pid ;;; ;;; Where to wait for clients ;;; ; ip address or * which means all ip-s listen_addr = * listen_port = 6432 unix_socket_dir = /var/run/postgresql ;;; ;;; Authentication settings ;;; ; any, trust, plain, crypt, md5 auth_type = plain #auth_file = 8.0/main/global/pg_auth auth_file = /etc/pgBouncer/userlist.txt ;;; ;;; Users allowed into database 'pgbouncer' ;;; ; comma-separated list of users, who are allowed to change settings ; user1, user2 admin_users = postgres ; comma-separated list of users who are just allowed to use SHOW command stats_users = stats, root ;;; ;;; Pooler personality questions ;;; ; When server connection is released back to pool: ; session - after client disconnects ; transaction - after transaction finishes ; statement - after statement finishes pool_mode = session ; ; Query for cleaning connection immidiately after releasing from client. ; ; Query for 8.3+: ; DISCARD ALL; ; ; Older versions: ; RESET ALL; SET SESSION AUTHORIZATION DEFAULT ; server_reset_query = ; ; Comma-separated list of parameters to ignore when given ; in startup packet. Newer JDBC versions require the ; extra_float_digits here. ; ;ignore_startup_parameters = extra_float_digits ; ; When taking idle server into use, this query is ran first. ; SELECT 1 ; server_check_query = select 1 ; If server was used more recently that this many seconds ago, ; skip the check query. Value 0 may or may not run in immidiately. server_check_delay = 10 ;;; ;;; Connection limits ;;; ; total number of clients that can connect max_client_conn = 100 default_pool_size = 20 ; how many additional connection to allow in case of trouble reserve_pool_size = 5 ; if a clients needs to wait more than this many seconds, use reserve pool ;reserve_pool_timeout = 3 log_connections = 1 log_disconnections = 1 ; log error messages pooler sends to clients log_pooler_errors = 1 ; If off, then server connections are reused in LIFO manner ;server_round_robin = 0 ;;; ;;; Timeouts ;;; ;; Close server connection if its been connected longer. ;server_lifetime = 1200 ;; Close server connection if its not been used in this time. ;; Allows to clean unneccessary connections from pool after peak. ;server_idle_timeout = 60 ;; Cancel connection attepmt if server does not answer takes longer. ;server_connect_timeout = 15 ;; If server login failed (server_connect_timeout or auth failure) ;; then wait this many second. ;server_login_retry = 15 ;; Dangerous. Server connection is closed if query does not return ;; in this time. Should be used to survive network problems, ;; _not_ as statement_timeout. (default: 0) ;query_timeout = 0 ;; Dangerous. Client connection is closed if no activity in this time. ;; Should be used to survive network problems. (default: 0) ;client_idle_timeout = 0 ;; Disconnect clients who have not managed to log in after connecting ;; in this many seconds. ;client_login_timeout = 60 ;; Clean automatically created database entries (via "*") if they ;; stay unused in this many seconds. ; autodb_idle_timeout = 3600 ;;; ;;; Low-level tuning options ;;; ;; buffer for streaming packets ;pkt_buf = 2048 ;; networking options, for info: man 7 tcp ;; linux: notify program about new connection only if there ;; is also data received. (Seconds to wait.) ;; On Linux the default is 45, on other OS'es 0. ;tcp_defer_accept = 0 ;; In-kernel buffer size (linux default: 4096) ;tcp_socket_buffer = 0 ;; whether tcp keepalive should be turned on (0/1) ;tcp_keepalive = 0 ;; following options are linux-specific. ;; they also require tcp_keepalive=1 ;; count of keepaliva packets ;tcp_keepcnt = 0 ;; how long the connection can be idle, ;; before sending keepalive packets ;tcp_keepidle = 0 ;; The time between individual keepalive probes. ;tcp_keepintvl = 0
Скрипт:
(Исходник в папке /etc исходников. Я менял пути в начале скрипта...)
#!/bin/bash # # pgbouncer Start the PgBouncer PostgreSQL pooler. # # The variables below are NOT to be changed. They are there to make the # script more readable. NAME=pgbouncer DAEMON=/usr/local/bin/$NAME PIDFILE=/var/run/postgresql/$NAME.pid CONF=/etc/pgBouncer/$NAME.ini OPTS="-d $CONF -u postgres" # note: SSD is required only at startup of the daemon. SSD=`which start-stop-daemon` ENV="env -i LANG=C PATH=/bin:/usr/bin:/usr/local/bin" trap "" 1 # Check if configuration exists test -f $CONF || exit 0 case "$1" in start) echo -n "Starting server: $NAME" $ENV $SSD --start --pidfile $PIDFILE --exec $DAEMON -- $OPTS > /dev/null ;; stop) echo -n "Stopping server: $NAME" start-stop-daemon --stop --pidfile $PIDFILE ;; reload | force-reload) echo -n "Reloading $NAME configuration" start-stop-daemon --stop --pidfile $PIDFILE --signal HUP ;; restart) $0 stop $0 start ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart}" exit 1 ;; esac if [ $? -eq 0 ]; then echo . exit 0 else echo " failed" exit 1 fi
Для автозапуска сделать файл pgbouncer gj пути /etc/default/ с содержимым:
START=1
Теперь подключатся нужно к порту 6432 (Он, кстати, стал стандартом...).
Вобщем у меня всё заработало.
Для просмотра диагностики pgBouncer`a
sudo psql -p 6432 pgbouncer -U postgres
Список команд - тут.
Для затравки:
show help;
show pools;
show clients;