Configuring EDB Pgpool-II v4
The configuration files are created in the /etc/sysconfig/edb/pgpool<x.y>
directory, where <x.y> is the EDB Pgpool-II release version. By default, .sample
is appended to the configuration file name. remove .sample
from the configuration file after copying the file to create your custom configuration.
Note
The configuration options for Pgpool-II are extensive. Consider the options listed here as a starting point. For more information about configuring and using Pgpool-II, consult the project website.
Commonly used parameters
The table lists pgpool.conf
parameters to use when implementing connection pooling:
Parameter name | Description |
---|---|
listen_addresses | Hostname or IP address used by EDB Pgpool-II to listen for connections. The default is localhost . Change to '*' for all addresses. |
port | Port for EDB Pgpool-II connections. The default is 9999 . |
pcp_port | Port for PCP connections. The default is 9898 . |
backend_hostname0 | Hostname or IP address for backend 0. You can specify '' if the backend and EDB Pgpool-II are running on the same host. |
backend_port0 | Port number for backend 0. |
backend_weight0 | Weight for backend 0 (only in load balancing mode). Specify 1 for each backend if you want to balance the load equally or decimal values (.9 , .1 , etc.) to weigh the load toward specific backends. |
backend_data_directory0 | Data directory for backend 0. |
enable_pool_hba | Set to on to use pool_hba.conf for client authentication. |
num_init_children | Number of pools. Default is 32 . |
max_pool | Number of connections per pool. Default is 4 . |
connection_cache | Set to on to enable connection pooling. |
pool_conn_dbname | Database name to which EDB Pgpool-II connects. By default, EDB Pgpool-II connects with Postgres. As of v4.3, the deprecated pool_conn_dbname parameter is removed. |
sr_check_user | User name to perform streaming replication check. Required as of EDB Pgpool-II v4.3. |
sr_check_password | Password of the sr_check_user user to perform the streaming replication checks. Required as of EDB Pgpool-II v4.3. |
The following table lists pgpool.conf
parameters to use when implementing replication and load balancing:
Parameter name | Description |
---|---|
Allow_sql_comments | If on, ignore SQL comments. Changes to this parameter require reloading the pgpool.conf file. |
load_balance_mode | Set to on to activate load balancing mode. If load_balance_mode is on and replicate_select is off, SELECT statements are sent to one backend. The parameter backend_weight<N>.z determines the proportion of SELECT statements each backend receives. |
ignore_leading_white_space | Ignore leading white spaces of each query. Certain APIs such as DBI/DBD::Pg for Perl add white space that you can't control. Default is on . |
Configuring connection pooling
EDB Pgpool-II provides a set of child processes that maintain cached connections to one or more database servers. When a client connects, EDB Pgpool-II attempts to reuse a connection from its pool, thus avoiding the overhead of opening and closing client connections.
You can reuse a connection in the pool only if the target database and the connection user match a prior connection that is currently in the pool. The pgpool.conf
file specifies the connection pooling configuration options (such as the number of child processes and the maximum number of cached connections per child).
To configure connection pooling with one database server:
Configure the
pg_hba.conf
file on thePgpool-II
host to permit connections between the clients and the server.Copy the
pgpool.conf.sample
file topgpool.conf
, modify the file, set theconnection_cache
parameter toon
, and specify connection properties for your database server.The following example shows how to connect with the EDB Postgres Advanced Server:
The following example shows how to connect with the PostgreSQL Server:
Note
In the
pgpool.conf
file, connection parameters have an appended digit that specifies a cluster node identifier. Database node0
specifies values for the primary node.Optionally, configure EDB Pgpool-II client authentication.
Optionally, configure the PCP administrative interface.
Start EDB Pgpool-II: