Table of Contents Previous Next


10 Appendix A - Configuring Streaming Replication

In the example that follows, we will use a .pgpass file to enable md5 authentication for the replication user – this may or may not be the safest authentication method for your environment. For more information about the supported authentication options, please see the PostgreSQL core documentation at:
Connect to the master node of the replication scenario, and modify the pg_hba.conf file (located in the data directory under your Postgres installation), adding connection information for the replication user (in our example, edbrepuser):
Modify the postgresql.conf file (located in the data directory, under your Postgres installation), adding the following replication parameter and values to the end of the file:
Use the sudo su – command to assume the identity of the enterprisedb database superuser:
Then, start a psql session, connecting to the edb database:
At the psql command line, create a user with the replication attribute:
With your choice of editor, create a .pgpass file in the home directory of the enterprisedb user. The .pgpass file holds the password of the replication user in plain-text form; if you are using a .pgpass file, you should ensure that only trusted users have access to the .pgpass file:
The server will enforce restrictive permissions on the .pgpass file; use the following command to set the file permissions:
You must stop the database server before replacing the data directory on the Standby node with the data directory of the Master node. Use the command:
Then, delete the data directory on the Standby node:
After deleting the existing data directory, move into the bin directory and use the pg_basebackup utility to copy the data directory of the Master node to the Standby:
cd /opt/edb/as9.6/bin
./pg_basebackup –R –D /opt/edb/as9.6/data
--host=146.148.46.44 –-port=5444
--username=edbrepuser --password
The call to pg_basebackup specifies the IP address of the Master node and the name of the replication user created on the Master node. For more information about the options available with the pg_basebackup utility, see the PostgreSQL core documentation at:
When prompted by pg_basebackup, provide the password associated with the replication user.
After copying the data directory, change ownership of the directory to the database superuser (enterprisedb):
Navigate into the data directory:
With your choice of editor, create a file named recovery.conf( in the /opt/PostgresPlus/9.xAS/data directory) that includes:
standby_mode = on
primary_conninfo = 'host=146.148.46.44 port=5444 user=edbrepuser sslmode=prefer sslcompression=1 krbsrvname=postgres'

trigger_file = '/opt/edb/as9.6/data/mytrigger'
restore_command = '/bin/true'
recovery_target_timeline = 'latest'
Please note: the primary_conninfo parameter specifies connection information for the replication user on the master node of the replication scenario.
Change ownership of the recovery.conf file to enterprisedb:
Modify the postgresql.conf file (located in data directory, under the Postgres installation), specifying the following values at the end of the file:
If you connect to the Standby with the psql client and query the pg_is_in_recovery() function, the server will reply:

10 Appendix A - Configuring Streaming Replication

Table of Contents Previous Next