PGBOUNCER(1) Databases PGBOUNCER(1) (NAME) pgbouncer - PostgreSQL (SYNOPSIS) pgbouncer [-d][-R][-v][-u user] pgbouncer -V|-h : pgbouncer.exe [-v][-u user] pgbouncer.exe -V|-h : pgbouncer.exe --regservice pgbouncer.exe --unregservice (DESCRIPTION) pgbouncer (connection pooler) PostgreSQL . pgbouncer PostgreSQL pgbouncer . pgbouncer PostgreSQL . pgbouncer (pooling) : Session pooling . . . . Transaction pooling . PgBouncer . Statement pooling . (query) . (Multi-statement) . pgbouncer SHOW "" pgbouncer . (QUICK-START) : 1. pgbouncer.ini . pgbouncer(5) . : [databases] template1 = host=localhost port=5432 dbname=template1 [pgbouncer] listen_port = 6432 listen_addr = localhost auth_type = md5 auth_file = userlist.txt logfile = pgbouncer.log pidfile = pgbouncer.pid admin_users = someuser 2. userlist.txt : "someuser" "same_password_as_in_server" 3. pgbouncer: $ pgbouncer -d pgbouncer.ini 4. ( psql) PostgreSQL pgbouncer : $ psql -p 6432 -U someuser template1 5. pgbouncer SHOW HELP; pgbouncer : $ psql -p 6432 -U someuser pgbouncer pgbouncer=# SHOW HELP; NOTICE: Console usage DETAIL: SHOW [HELP|CONFIG|DATABASES|FDS|POOLS|CLIENTS|SERVERS|SOCKETS|LISTS|VERSION|...] SET key = arg RELOAD PAUSE SUSPEND RESUME SHUTDOWN [...] 6. pgbouncer.ini : pgbouncer=# RELOAD; -d, --daemon . . (daemon) pidfile logfile syslog . stderr . : pgbouncer . -R, --reboot : (rolling restart) pgbouncer so_reuseport (online restart) . . . : unix_socket_dir . . TLS . -u USERNAME, --user=USERNAME . -v, --verbose (verbosity). . -q, --quiet : stderr . stderr . init.d. -V, --version . -h, --help . --regservice Win32: PgBouncer . service_name . --unregservice Win32: . (ADMIN CONSOLE) pgbouncer : $ psql -p 6432 pgbouncer admin_users stats_users . ( auth_type=any stats_user .) UID pgbouncer . (simple query protocol) . (extended query protocol) . (Show commands) SHOW . . SHOW STATS . stats_period . database . total_xact_count SQL (pooled) pgbouncer. total_query_count SQL pgbouncer. total_server_assignment_count . total_received pgbouncer . total_sent pgbouncer . total_xact_time pgbouncer PostgreSQL idle in transaction . total_query_time pgbouncer PostgreSQL . total_wait_time . . total_client_parse_count (prepared statements) . max_prepared_statements . total_server_parse_count pgbouncer . max_prepared_statements . total_bind_count (bind) pgbouncer PostgreSQL . max_prepared_statements . avg_xact_count . avg_query_count . avg_server_assignment_count . avg_recv ( ) . avg_sent ( ) . avg_xact_time . avg_query_time . avg_wait_time ( stats_period ). avg_client_parse_count . max_prepared_statements . avg_server_parse_count pgbouncer . max_prepared_statements . avg_bind_count (bind) pgbouncer PostgreSQL . max_prepared_statements ..SS SHOW STATS_TOTALS SHOW STATS (total_) . SHOW STATS_AVERAGES SHOW STATS (avg_) . SHOW TOTALS SHOW STATS . SHOW SERVERS type S . user pgbouncer . database . replication . none logical physical . state PgBouncer active idle used tested new active_cancel being_canceled. addr IP PostgreSQL. port PostgreSQL. local_addr . local_port . connect_time . request_time . wait . wait_us . close_needed DNS RECONNECT . ptr . link . remote_pid (PID) backend. Unix PID . (cancel packet) PostgreSQL PID PgBouncer . tls TLS TLS . application_name application_name . prepared_statements (prepared statements) . max_prepared_statements . id . SHOW CLIENTS type C . user . database . replication . none logical physical . state active ( ) idle ( ) waiting active_cancel_req waiting_cancel_req. addr IP . port . local_addr . local_port . connect_time . request_time . wait . wait_us . close_needed . ptr . link . remote_pid (PID) Unix . tls TLS TLS . application_name application_name . prepared_statements (prepared statements) . id ..SS SHOW POOLS (database, user) . database . user . cl_active (idle) . cl_waiting . cl_active_cancel_req . cl_waiting_cancel_req . sv_active . sv_active_cancel . sv_being_canceled . sv_idle . sv_used server_check_delay server_check_query . sv_tested server_reset_query server_check_query . sv_login (login) . maxwait () . . pool_size . maxwait_us . pool_mode (pooling mode) . load_balance_hosts load_balance_hosts . SHOW PEER_POOLS (peer) peer_pool . database (ID) . cl_active_cancel_req . cl_waiting_cancel_req . sv_active_cancel . sv_login . SHOW LISTS ( ): databases . users . pools . free_clients . PgBouncer . used_clients . login_clients login. free_servers . PgBouncer . used_servers . dns_names DNS (cache). dns_zones DNS . dns_queries DNS (in-flight). dns_pending ..SS SHOW USERS name . pool_size pool_size NULL. reserve_pool_size reserve_pool_size NULL. pool_mode pool_mode NULL. max_user_connections max_user_connections . . current_connections . max_user_client_connections max_user_client_connections . . current_client_connections PgBouncer . SHOW DATABASES name . host PgBouncer . port PgBouncer . database PgBouncer . force_user PgBouncer PostgreSQL . pool_size . min_pool_size . reserve_pool_size . server_lifetime . pool_mode pool_mode NULL . load_balance_hosts load_balance_hosts host . max_connections max_db_connections . current_connections . max_client_connections PgBouncer max_db_client_connections . current_client_connections . paused 1 0. disabled 1 0. SHOW PEERS peer_id . host PgBouncer . port PgBouncer . pool_size . SHOW FDS - . "pgbouncer" Unix UID FD . (online restart) . : Windows . PgBouncer . fd . task pooler client server. user FD . database FD . addr IP FD unix Unix . port FD . cancel (cancel key) . link fd / . NULL..SS SHOW SOCKETS, SHOW ACTIVE_SOCKETS . SHOW CLIENTS SHOW SERVERS . SHOW CONFIG : key value default changeable yes no . no . SET . SHOW MEM . . SHOW DNS_HOSTS DNS . hostname . ttl . addrs . SHOW DNS_ZONES DNS . zonename . serial . count . SHOW VERSION PgBouncer . SHOW STATE PgBouncer . active paused suspended. (Process controlling commands) PAUSE [db] PgBouncer . (pooling mode) ( ). . . . RESUME . DISABLE db . ENABLE db DISABLE. RECONNECT [db] ( ) . . . pgbouncer.ini ( RELOAD) DNS . PgBouncer . . . PAUSE . ( ) KILL . KILL [db] admin. RESUME . KILL_CLIENT id . id SHOW CLIENTS . KILL_CLIENT 1234 . SUSPEND PgBouncer . . PgBouncer. RESUME ..SS RESUME [db] KILL PAUSE SUSPEND. SHUTDOWN PgBouncer . SHUTDOWN WAIT_FOR_SERVERS . PAUSE SHUTDOWN PAUSE . UNIX PgBouncer . SHUTDOWN WAIT_FOR_CLIENTS . UNIX pgbouncer . (zero-downtime rolling restart) PgBouncer : 1. PgBouncer so_reuseport ( peering ). . 2. A . 3. SHUTDOWN WAIT_FOR_CLIENTS A ( SIGTERM ). 4. . server_idle_timeout ( ) . . A . 5. A . 6. . RELOAD PgBouncer . auth_file auth_hba_file . PgBouncer . ( pooling) . WAIT_CLOSE [db] "close_needed" ( SHOW SERVERS). RECONNECT RELOAD switchover. (Other commands) SET key = arg ( SHOW CONFIG). : SET log_connections = 1; SET server_check_query = 'select 2'; ( PgBouncer PgBouncer . SET SQL PostgreSQL .) (Signals) SIGHUP . RELOAD . SIGTERM (Super safe shutdown). . SHUTDOWN WAIT_FOR_CLIENTS . " " " " . PgBouncer 1.23.0 " " . SIGINT (Safe shutdown). SHUTDOWN WAIT_FOR_SERVERS . " " " " . SIGQUIT (Immediate shutdown). SHUTDOWN . SIGUSR1 PAUSE . SIGUSR2 RESUME . Libevent (Libevent settings) Libevent: epoll kqueue devpoll poll select EVENT_NOEPOLL EVENT_NOKQUEUE EVENT_NODEVPOLL EVENT_NOPOLL EVENT_NOSELECT . EVENT_SHOW_METHOD libevent . pgbouncer(5) - 1.25.2 PGBOUNCER(1)