-
+
High Availability, Load Balancing, and Replication
PostgreSQL> includes a simple streaming replication
mechanism, which lets the standby server to stay more up-to-date than
- file-based replication allows. The standby connects to the primary
+ file-based log shipping allows. The standby connects to the primary
and the primary starts streaming WAL records from where the standby
left off, and continues streaming them as they are generated, without
waiting for the WAL file to be filled. So with streaming replication,
- Set up connections and authentication so that the standby server can
- successfully connect to the pseudo replication> database of
- the primary server (see
- ). Ensure that
- and pg_hba.conf> are
- configured appropriately on the primary.
+ Set and authentication options
+ (see pg_hba.conf>) so that the standby server can connect to
+ the pseudo replication> database of the primary server (see
+ ).
On systems that support the keepalive socket option, setting
,
and
- helps you to find the
- troubles with replication (e.g., the network outage or the failure of
- the standby server) as soon as possible.
+ helps the master to notice
+ a broken connection promptly.
(see for details).
-
- Enable WAL archiving in the primary server because we need to make a base
- backup of it later (see and
- for details).
-
-
Start the
PostgreSQL> server on the primary.
- Set up WAL archiving, connections and authentication like the primary
- server, because the standby server might work as a primary server after
- failover. Ensure that your settings are consistent with the
- future> environment after the primary and the standby
- server are interchanged by failover. If you're setting up the standby
- server for e.g reporting purposes, with no plans to fail over to it,
- configure the standby accordingly.
+ If you're setting up the standby server for high availability purposes,
+ set up WAL archiving, connections and authentication like the primary
+ server, because the standby server will work as a primary server after
+ failover. If you're setting up the standby server for e.g reporting
+ purposes, with no plans to fail over to it, configure the standby
+ accordingly.
Specifies whether to start the
PostgreSQL> server as
- a standby. If this parameter is on>, the streaming
- replication is enabled and the standby server will try to connect
- to the primary to receive and apply WAL records continuously. The
- default is off>, which allows only an archive recovery
- without replication. So, streaming replication requires this
- parameter to be explicitly set to on>.
+ a standby. If this parameter is on>, the server will
+ not end recovery when the end of archived WAL is reached, but
+ will keep trying to continue recovery using restore_command>
+ and by connecting to the primary server as specified by
+ primary_conninfo> setting.
+
+
+
+
+ restore_command (string)
+ restore_end_command (string)
+
+ In standby-mode, restore_command> (and restore_end_command>) is set to a
+ simple command or script like in PITR. pg_standby or similar tools
+ that wait for the next WAL file to arrive, cannot be used with
+ streaming replication, as the server handles retries and waiting
+ itself. Set restore_command> as you would if you were
+ recovering using a Continuous archiving backup (see ).
the password needs to be set if the primary demands password
authentication.
+ This setting has no effect if standby_mode> is off>.
+
trigger_file (string)
- Specifies a trigger file whose presence activates the standby.
- If no trigger file is specified, the standby never exits
+ Specifies a trigger file whose presence ends recovery in the
+ standby. If no trigger file is specified, the standby never exits
recovery.
+ This setting has no effect if standby_mode> is off>.
+