Setting up replication and load balancing

To set up pgpool, we can simply take an existing sample file containing a typical configuration, copy it to our configuration directory, and modify it:

$ cp /usr/local/etc/pgpool.conf.sample /usr/local/etc/pgpool.conf

It is a lot easier to just adapt this config file than to write things from scratch. In the following listing, you will see a sample config that you can use for a simple two-node setup:

listen_addresses = '*' port = 9999 socket_dir = '/tmp' pcp_port = 9898 pcp_socket_dir = '/tmp' backend_hostname0 = 'localhost' backend_port0 = 5432 backend_weight0 = 1 backend_data_directory0 = '/home/hs/db' backend_flag0 = 'ALLOW_TO_FAILOVER' backend_hostname1 = 'localhost' backend_port1 = 5433 backend_weight1 ...

Get PostgreSQL Replication - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.