Pgbouncer Administrator Handbook

Source: Internet
Author: User
Tags connection pooling crypt md5 postgresql syslog
[Edit] Pgbouncer (5)
Directory [Hide] 1 pgbouncer (5) 1.1 name 1.2 Summary 1.3 Description 1.4 [Pgbouncer] segment 1.4.1 Common settings logfile pidfile listen_addr listen_port unix_socket_dir auth_file auth_type pool_mode max_client_conn default_pool_size server_round_robin 1.4.2 Log Settings syslog syslog_facility log_conn Ections log_disconnections log_pooler_errors 1.4.3 Console access control admin_users stats_users 1.4.4 Company Connect health Check, timeout server_reset_query server_check_delay server_check_query server_lifetime server_idle_timeout server_connect_timeout server_login_retry client_login_timeout 1.4.5 Dangerous timeout query_timeout client_idle_timeout 1.4.6 The underlying network settings pkt_buf tcp_defer_accept Tcp_socket_buffer tcp_keepalive tcp_keepcnt tcp_keepidle TCP_KEEPINTVL 1.5 [Databases] section 1.5.1 Position parameter dbname Host Port User, password 1.5.2 connection pool size per database pool_size 1.5.3 additional parameters client_encoding E TimeZone 1.6 example 1.7 see Also
[Edit] name

Pgbouncer-postgresql a lightweight connection pool. [edit] Summary

[databases] db = ...

[Pgbouncer] ... [Edit] Description

The configuration file is in "INI" format. The name of the segment is between "and". To Or the line that begins with ' "is treated as a comment and is ignored. ";" appearing at a point other than the beginning of the line. and ' "will not be recognized. [Edit] [pgbouncer] section [edit] Common settings [edit] logfile

Declares a log file. The log file is kept open until Kill-hup or RELOAD on the console; After the completion.

Default: Not set. [edit] pidfile

Declare the PID file. It is not allowed to be a daemon without pidfile.

Default: No settings. [edit] listen_addr

Declares a IPV4 address for listening on a TCP connection. or * means "listen to all the addresses." If not set, only UNIX socket connections are allowed.

Default: No settings [edit] listen_port

which port to monitor. Applies to TCP and UNIX sockets.

Default: 6000 [edit] unix_socket_dir

Declares the location of the Unix socket. Applies to listening for sockets and server connections. If set to an empty string, the Unix socket is closed.

Default:/tmp [edit] auth_file

The user name and password are loaded from this file. The file format used is the same as the PostgreSQL pg_auth/pg_pwd file, so you can point directly to the backend file.

Default: Not set. [edit] auth_type

How to authenticate users.

MD5 use MD5 as the basis for password checking. Auth_file can contain MD5 encrypted or plaintext passwords. The default value.

Crypt uses crypt (3) as the basis for password checking. Auth_file must contain a plaintext password.

Plain is sending a plaintext password on the line.

Trust does not do certification. The user name must still exist in the auth_file.

Any like trust, but given the user name is ignored. All databases are required to be configured to log on with a specific user. [edit] pool_mode

Declares when a server connection is marked for reuse by another client.

Session after the client disconnects, the server releases back to the connection pool. Default.

The Transaction Server releases back to the connection pool after the transaction completes.

Statement after the query has finished, the server releases the connection pool back. Long transactions spanning multiple statements are not allowed in this mode. [edit] max_client_conn

The maximum number of client connections allowed. If you increase this value, it is best to increase the file descriptor limit as well. Please note that the actual number of file descriptors is always more than max_client_conn. The maximum number of descriptors to be used theoretically is:

  Max_client_conn + (max_pool_size * total_databases * total_users)

This assumes that each user is connecting to the server with its user name. If the database user declares in the connection string (all users are connected to the same user), then the maximum value of the theory is:

  Max_client_conn + (Max_pool_size * total_databases)

The maximum theoretical value should never be achieved unless someone intentionally designed a special load for him. Still, it means you should give FD some space.

Look at the Ulimit in your favorite hand album.

Default: [edit] default_pool_size

The number of allowed server connections per user/database. Can be overridden in database-related configurations.

Default: [edit] Server_round_robin

By default, pgbouncer the server-side connection in a LIFO manner, so that most of the load is borne by a small number of connections. This is the best performance when you have only one server to do database service. But if there is a TCP rotation mechanism behind the database IP, then it's best to use the pbcouncer, so that you can get a consistent load.

Default: 0 [Edit] Log Settings [edit] syslog

Toggle Syslog on/Off

Default: 0 [edit] syslog_facility

Under what facilities is the log sent to the syslog. May be: autho,authopriv,daemon,user,local0-7

Default: Daemon [edit] log_connections

Log logs that have been successfully logged.

Default: 1 [edit] log_disconnections

Record the reason for the disconnect.

Default: 1 [edit] log_pooler_errors

Logs the error log that connection Chi Fa sent to the client.

Default: 1 [Edit] Console access control [edit] admin_users

Lists all users who are allowed to run commands on the console.

Default: Empty [edit] stats_users

Lists the users who are allowed to run read-only queries on the console. This means all the show commands except show FDS.

default: Empty. [edit] Connect health Check, timeout [edit] server_reset_query

When the connection is released, the server can be used by other clients before the server is sent to the query. At that point, there is no transaction in process, so it should not include ABORT or ROLLBACK.

8.2 and earlier versions of the better way are:

Server_reset_query = Reset All; SET session AUTHORIZATION DEFAULT;

For a 8.3 or higher version, we can do this:

Server_reset_query = Discard all; [edit] Server_check_delay

How long to keep a freed connection in the immediate available state without performing a health query. If 0, the query is always running.

Default: [edit] Server_check_query

Simply do nothing for the query to check whether the server connection is alive.

If it is an empty string, then the health check is turned off.

Default: SELECT 1; [edit] Server_lifetime

Connection pooling attempts to turn off server connections that have been connected longer than this value.

Default: 3600 [edit] Server_idle_timeout

If the server connection is idle longer than this, there is too much connectivity in the connection pool, so this can be turned off.

Default: [edit] Server_connect_timeout

If the connection and login will not be completed during this time, the connection will be closed.

Default: [edit] Server_login_retry

If the login failed to authenticate from connect (), the connection pool waits for the time and then tries to reconnect.

Default: [edit] Client_login_timeout

If the client logs on, but cannot complete the login during this time, it will be disconnected. The main purpose is to avoid dead connections that are still SUSPEND and thus lead to online reboots.

Default: [Edit] Dangerous timeout

Set the following timeout for unknown reasons. [edit] Query_timeout

Queries that run longer than this section are canceled. This should be used in conjunction with smaller server-side statement_timeout to help deal with network problems only.

Default: 0 (OFF) [edit] Client_idle_timeout

Client connections are managed when they are idle for more than this period of time. This should be longer than the lifetime of the client connection, so that only network problems can be handled.

default: 0 (OFF) [edit] The underlying network settings [edit] pkt_buf

The internal buffer size used for the network package. Affects the TCP packet emitted and the general memory usage. The actual LIBPQ package can be larger than this, so there is no need to set it too large.

Default: 2048 [edit] tcp_defer_accept

The details of the following options should be obtained from Man 7 TCP

Default: In Linux is 45, otherwise it is 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.